diff --git a/60hz_Divider/docs/15.log b/60hz_Divider/docs/15.log index 75d3d9c..cf1e98d 100644 --- a/60hz_Divider/docs/15.log +++ b/60hz_Divider/docs/15.log @@ -1,4 +1,4 @@ -This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 3 AUG 2020 03:08 +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 01:03 entering extended mode restricted \write18 enabled. %&-line parsing enabled. diff --git a/60hz_Divider/docs/15.pdf b/60hz_Divider/docs/15.pdf index 23856f1..b805823 100644 Binary files a/60hz_Divider/docs/15.pdf and b/60hz_Divider/docs/15.pdf differ diff --git a/60hz_Divider/docs/16.aux b/60hz_Divider/docs/16.aux new file mode 100644 index 0000000..2387151 --- /dev/null +++ b/60hz_Divider/docs/16.aux @@ -0,0 +1,15 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}60Hz Divider}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Overview}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 60 Hz Logic Divider to 1Hz\relax }}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.\relax }}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display}{6}} +\@writefile{toc}{\contentsline {section}{\numberline {2}Project Rev A Complete}{6}} diff --git a/60hz_Divider/docs/16.log b/60hz_Divider/docs/16.log new file mode 100644 index 0000000..47a444d --- /dev/null +++ b/60hz_Divider/docs/16.log @@ -0,0 +1,295 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 01:50 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +60hz_Divider/docs/16.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/6 +0hz_Divider/docs/16.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./16.aux) +\openout1 = `16.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(./16.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 2. +) +\tf@toc=\write3 +\openout3 = `16.toc'. + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 24. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 24. + <../pics/DSCN2964.JPG, id=1, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2964.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2964.JPG used on input line 26. +(pdftex.def) Requested size: 150.556pt x 112.91699pt. + [1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} <../pics/DSCN2964.JPG>] +Overfull \hbox (88.69052pt too wide) in paragraph at lines 65--65 +[] \OT1/cmtt/m/n/10.95 ***** These pin numbers will probably not work with your + hardware *****[] + [] + +[2] <../pics/DSCN2958.JPG, id=17, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2958.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2958.JPG used on input line 88. +(pdftex.def) Requested size: 200.74644pt x 150.55983pt. + [3] [4 <../pics/DSCN2958.JPG>] [5] +Overfull \hbox (13.65749pt too wide) in paragraph at lines 127--128 +\OT1/cmr/m/n/10.95 Reference: http://maxembedded.com/2011/06/port-operations-in +-avr/ + [] + +[6] (./16.aux) ) +Here is how much of TeX's memory you used: + 3528 strings out of 494945 + 53560 string characters out of 6181032 + 118035 words of memory out of 5000000 + 6801 multiletter control sequences out of 15000+600000 + 8977 words of font info for 32 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,39p,694b,267s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 16.pdf (6 pages, 488191 bytes). +PDF statistics: + 53 PDF objects out of 1000 (max. 8388607) + 35 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 11 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/60hz_Divider/docs/16.pdf b/60hz_Divider/docs/16.pdf new file mode 100644 index 0000000..988eb8e Binary files /dev/null and b/60hz_Divider/docs/16.pdf differ diff --git a/60hz_Divider/docs/16.tex b/60hz_Divider/docs/16.tex new file mode 100644 index 0000000..d4775f8 --- /dev/null +++ b/60hz_Divider/docs/16.tex @@ -0,0 +1,140 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations of the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. + +\textbf{Problems:} The timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. This is likely because I quickly prototyped with digitalRead. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display} +I've + + +\section{Project Rev A Complete} +After another night or two of work, I have a working prototype. + + +\end{document} + diff --git a/60hz_Divider/docs/16.tex~ b/60hz_Divider/docs/16.tex~ new file mode 100644 index 0000000..dad7e61 --- /dev/null +++ b/60hz_Divider/docs/16.tex~ @@ -0,0 +1,122 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations of the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. + +\textbf{Problems:} The timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. This is likely because I quickly prototyped with digitalRead. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} + +\end{verbatim} + +may fix these issues. + +\section{Project Rev A Complete} +After another night or two of work, I have a working prototype. + + +\end{document} + diff --git a/60hz_Divider/docs/16.toc b/60hz_Divider/docs/16.toc new file mode 100644 index 0000000..81fa60d --- /dev/null +++ b/60hz_Divider/docs/16.toc @@ -0,0 +1,12 @@ +\contentsline {section}{\numberline {1}60Hz Divider}{1} +\contentsline {subsection}{\numberline {1.1}Overview}{1} +\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2} +\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2} +\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3} +\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3} +\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3} +\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4} +\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{4} +\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5} +\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display}{6} +\contentsline {section}{\numberline {2}Project Rev A Complete}{6} diff --git a/60hz_Divider/docs/17.aux b/60hz_Divider/docs/17.aux new file mode 100644 index 0000000..0cff7b9 --- /dev/null +++ b/60hz_Divider/docs/17.aux @@ -0,0 +1,15 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}60Hz Divider}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Overview}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 60 Hz Logic Divider to 1Hz\relax }}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.\relax }}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6}} +\@writefile{toc}{\contentsline {section}{\numberline {2}Project Rev A Complete}{7}} diff --git a/60hz_Divider/docs/17.log b/60hz_Divider/docs/17.log new file mode 100644 index 0000000..3900e8d --- /dev/null +++ b/60hz_Divider/docs/17.log @@ -0,0 +1,311 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 01:57 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +60hz_Divider/docs/17.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/6 +0hz_Divider/docs/17.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./17.aux) +\openout1 = `17.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(./17.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 2. +) +\tf@toc=\write3 +\openout3 = `17.toc'. + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 24. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 24. + <../pics/DSCN2964.JPG, id=1, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2964.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2964.JPG used on input line 26. +(pdftex.def) Requested size: 150.556pt x 112.91699pt. + [1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] +Overfull \hbox (88.69052pt too wide) in paragraph at lines 65--65 +[] \OT1/cmtt/m/n/10.95 ***** These pin numbers will probably not work with your + hardware *****[] + [] + +[2 <../pics/DSCN2964.JPG>] [3] +<../pics/DSCN2958.JPG, id=20, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2958.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2958.JPG used on input line 88. +(pdftex.def) Requested size: 200.74644pt x 150.55983pt. + [4 <../pics/DSCN2958.JPG>] [5] +Overfull \hbox (13.65749pt too wide) in paragraph at lines 127--128 +\OT1/cmr/m/n/10.95 Reference: http://maxembedded.com/2011/06/port-operations-in +-avr/ + [] + + +Overfull \hbox (19.70627pt too wide) in paragraph at lines 170--170 +[]\OT1/cmtt/m/n/10.95 //https://playground.arduino.cc/Main/LedControl/#Seg7Cont +rol[] + [] + +[6] +LaTeX Font Info: Try loading font information for OMS+cmr on input line 179. + + (/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 179. + [7] [8] (./17.aux) ) +Here is how much of TeX's memory you used: + 3544 strings out of 494945 + 53853 string characters out of 6181032 + 119035 words of memory out of 5000000 + 6815 multiletter control sequences out of 15000+600000 + 8977 words of font info for 32 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,39p,694b,291s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 17.pdf (8 pages, 499283 bytes). +PDF statistics: + 65 PDF objects out of 1000 (max. 8388607) + 44 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 11 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/60hz_Divider/docs/17.pdf b/60hz_Divider/docs/17.pdf new file mode 100644 index 0000000..dbb54ce Binary files /dev/null and b/60hz_Divider/docs/17.pdf differ diff --git a/60hz_Divider/docs/17.tex b/60hz_Divider/docs/17.tex new file mode 100644 index 0000000..0871cff --- /dev/null +++ b/60hz_Divider/docs/17.tex @@ -0,0 +1,191 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations of the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. + +\textbf{Problems:} The timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. This is likely because I quickly prototyped with digitalRead. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\section{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/17.tex~ b/60hz_Divider/docs/17.tex~ new file mode 100644 index 0000000..d4775f8 --- /dev/null +++ b/60hz_Divider/docs/17.tex~ @@ -0,0 +1,140 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations of the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. + +\textbf{Problems:} The timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. This is likely because I quickly prototyped with digitalRead. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display} +I've + + +\section{Project Rev A Complete} +After another night or two of work, I have a working prototype. + + +\end{document} + diff --git a/60hz_Divider/docs/17.toc b/60hz_Divider/docs/17.toc new file mode 100644 index 0000000..1e16e0a --- /dev/null +++ b/60hz_Divider/docs/17.toc @@ -0,0 +1,12 @@ +\contentsline {section}{\numberline {1}60Hz Divider}{1} +\contentsline {subsection}{\numberline {1.1}Overview}{1} +\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2} +\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2} +\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3} +\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3} +\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3} +\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4} +\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5} +\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5} +\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6} +\contentsline {section}{\numberline {2}Project Rev A Complete}{7} diff --git a/60hz_Divider/docs/18.aux b/60hz_Divider/docs/18.aux new file mode 100644 index 0000000..0cff7b9 --- /dev/null +++ b/60hz_Divider/docs/18.aux @@ -0,0 +1,15 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}60Hz Divider}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Overview}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 60 Hz Logic Divider to 1Hz\relax }}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.\relax }}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6}} +\@writefile{toc}{\contentsline {section}{\numberline {2}Project Rev A Complete}{7}} diff --git a/60hz_Divider/docs/18.log b/60hz_Divider/docs/18.log new file mode 100644 index 0000000..b71708c --- /dev/null +++ b/60hz_Divider/docs/18.log @@ -0,0 +1,311 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 02:03 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +60hz_Divider/docs/18.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/6 +0hz_Divider/docs/18.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./18.aux) +\openout1 = `18.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(./18.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 2. +) +\tf@toc=\write3 +\openout3 = `18.toc'. + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 24. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 24. + <../pics/DSCN2964.JPG, id=1, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2964.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2964.JPG used on input line 26. +(pdftex.def) Requested size: 150.556pt x 112.91699pt. + [1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] +Overfull \hbox (88.69052pt too wide) in paragraph at lines 65--65 +[] \OT1/cmtt/m/n/10.95 ***** These pin numbers will probably not work with your + hardware *****[] + [] + +[2 <../pics/DSCN2964.JPG>] [3] +<../pics/DSCN2958.JPG, id=20, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2958.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2958.JPG used on input line 88. +(pdftex.def) Requested size: 200.74644pt x 150.55983pt. + [4 <../pics/DSCN2958.JPG>] [5] +Overfull \hbox (13.65749pt too wide) in paragraph at lines 129--130 +\OT1/cmr/m/n/10.95 Reference: http://maxembedded.com/2011/06/port-operations-in +-avr/ + [] + + +Overfull \hbox (19.70627pt too wide) in paragraph at lines 172--172 +[]\OT1/cmtt/m/n/10.95 //https://playground.arduino.cc/Main/LedControl/#Seg7Cont +rol[] + [] + +[6] +LaTeX Font Info: Try loading font information for OMS+cmr on input line 181. + + (/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 181. + [7] [8] (./18.aux) ) +Here is how much of TeX's memory you used: + 3545 strings out of 494945 + 53855 string characters out of 6181032 + 119035 words of memory out of 5000000 + 6815 multiletter control sequences out of 15000+600000 + 8977 words of font info for 32 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,39p,694b,291s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 18.pdf (8 pages, 500268 bytes). +PDF statistics: + 65 PDF objects out of 1000 (max. 8388607) + 44 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 11 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/60hz_Divider/docs/18.pdf b/60hz_Divider/docs/18.pdf new file mode 100644 index 0000000..6bdaf0c Binary files /dev/null and b/60hz_Divider/docs/18.pdf differ diff --git a/60hz_Divider/docs/18.tex b/60hz_Divider/docs/18.tex new file mode 100644 index 0000000..e8d0c38 --- /dev/null +++ b/60hz_Divider/docs/18.tex @@ -0,0 +1,195 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations on the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +Back to the 14 bit stream... + +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. \footnote{I didn't want to deal with coding the UART into the CPLD. There are also size limitations.} + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. I do have a start bit, and I am not outputting all the time, so this will be one 14 bit value every second. + +\textbf{Problems:} The Uno's digitalRead timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. e.g. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\section{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +It turns out that 4 digits on the display is the minimum for a project like this to be viable. 3 digits wouldn't be enough resolution, and 5 digits is not necessary (although nice). The values differ here from about 5996 to 6003 cycles per second. + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/18.tex~ b/60hz_Divider/docs/18.tex~ new file mode 100644 index 0000000..0871cff --- /dev/null +++ b/60hz_Divider/docs/18.tex~ @@ -0,0 +1,191 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations of the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. + +\textbf{Problems:} The timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. This is likely because I quickly prototyped with digitalRead. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\section{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/18.toc b/60hz_Divider/docs/18.toc new file mode 100644 index 0000000..1e16e0a --- /dev/null +++ b/60hz_Divider/docs/18.toc @@ -0,0 +1,12 @@ +\contentsline {section}{\numberline {1}60Hz Divider}{1} +\contentsline {subsection}{\numberline {1.1}Overview}{1} +\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2} +\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2} +\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3} +\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3} +\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3} +\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4} +\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5} +\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5} +\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6} +\contentsline {section}{\numberline {2}Project Rev A Complete}{7} diff --git a/60hz_Divider/docs/19.aux b/60hz_Divider/docs/19.aux new file mode 100644 index 0000000..c2149da --- /dev/null +++ b/60hz_Divider/docs/19.aux @@ -0,0 +1,15 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}60Hz Divider}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Overview}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 60 Hz Logic Divider to 1Hz\relax }}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.\relax }}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.9}Project Rev A Complete}{7}} diff --git a/60hz_Divider/docs/19.log b/60hz_Divider/docs/19.log new file mode 100644 index 0000000..a04b6b2 --- /dev/null +++ b/60hz_Divider/docs/19.log @@ -0,0 +1,311 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 02:04 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +60hz_Divider/docs/19.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/6 +0hz_Divider/docs/19.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./19.aux) +\openout1 = `19.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(./19.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 2. +) +\tf@toc=\write3 +\openout3 = `19.toc'. + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 24. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 24. + <../pics/DSCN2964.JPG, id=1, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2964.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2964.JPG used on input line 26. +(pdftex.def) Requested size: 150.556pt x 112.91699pt. + [1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] +Overfull \hbox (88.69052pt too wide) in paragraph at lines 65--65 +[] \OT1/cmtt/m/n/10.95 ***** These pin numbers will probably not work with your + hardware *****[] + [] + +[2 <../pics/DSCN2964.JPG>] [3] +<../pics/DSCN2958.JPG, id=20, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2958.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2958.JPG used on input line 88. +(pdftex.def) Requested size: 200.74644pt x 150.55983pt. + [4 <../pics/DSCN2958.JPG>] [5] +Overfull \hbox (13.65749pt too wide) in paragraph at lines 129--130 +\OT1/cmr/m/n/10.95 Reference: http://maxembedded.com/2011/06/port-operations-in +-avr/ + [] + + +Overfull \hbox (19.70627pt too wide) in paragraph at lines 172--172 +[]\OT1/cmtt/m/n/10.95 //https://playground.arduino.cc/Main/LedControl/#Seg7Cont +rol[] + [] + +[6] +LaTeX Font Info: Try loading font information for OMS+cmr on input line 181. + + (/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 181. + [7] [8] (./19.aux) ) +Here is how much of TeX's memory you used: + 3545 strings out of 494945 + 53855 string characters out of 6181032 + 119035 words of memory out of 5000000 + 6815 multiletter control sequences out of 15000+600000 + 8977 words of font info for 32 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,39p,694b,291s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 19.pdf (8 pages, 500270 bytes). +PDF statistics: + 65 PDF objects out of 1000 (max. 8388607) + 44 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 11 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/60hz_Divider/docs/19.pdf b/60hz_Divider/docs/19.pdf new file mode 100644 index 0000000..8296be3 Binary files /dev/null and b/60hz_Divider/docs/19.pdf differ diff --git a/60hz_Divider/docs/19.tex b/60hz_Divider/docs/19.tex new file mode 100644 index 0000000..5defbdb --- /dev/null +++ b/60hz_Divider/docs/19.tex @@ -0,0 +1,195 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations on the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +Back to the 14 bit stream... + +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. \footnote{I didn't want to deal with coding the UART into the CPLD. There are also size limitations.} + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. I do have a start bit, and I am not outputting all the time, so this will be one 14 bit value every second. + +\textbf{Problems:} The Uno's digitalRead timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. e.g. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\subsection{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +It turns out that 4 digits on the display is the minimum for a project like this to be viable. 3 digits wouldn't be enough resolution, and 5 digits is not necessary (although nice). The values differ here from about 5996 to 6003 cycles per second. + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/19.tex~ b/60hz_Divider/docs/19.tex~ new file mode 100644 index 0000000..e8d0c38 --- /dev/null +++ b/60hz_Divider/docs/19.tex~ @@ -0,0 +1,195 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations on the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +Back to the 14 bit stream... + +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. \footnote{I didn't want to deal with coding the UART into the CPLD. There are also size limitations.} + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. I do have a start bit, and I am not outputting all the time, so this will be one 14 bit value every second. + +\textbf{Problems:} The Uno's digitalRead timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. e.g. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\section{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +It turns out that 4 digits on the display is the minimum for a project like this to be viable. 3 digits wouldn't be enough resolution, and 5 digits is not necessary (although nice). The values differ here from about 5996 to 6003 cycles per second. + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/19.toc b/60hz_Divider/docs/19.toc new file mode 100644 index 0000000..ae76a37 --- /dev/null +++ b/60hz_Divider/docs/19.toc @@ -0,0 +1,12 @@ +\contentsline {section}{\numberline {1}60Hz Divider}{1} +\contentsline {subsection}{\numberline {1.1}Overview}{1} +\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2} +\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2} +\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3} +\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3} +\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3} +\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4} +\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{5} +\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5} +\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6} +\contentsline {subsection}{\numberline {1.9}Project Rev A Complete}{7} diff --git a/60hz_Divider/docs/20.aux b/60hz_Divider/docs/20.aux new file mode 100644 index 0000000..9d84acd --- /dev/null +++ b/60hz_Divider/docs/20.aux @@ -0,0 +1,15 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}60Hz Divider}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Overview}{1}} +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 60 Hz Logic Divider to 1Hz\relax }}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4}} +\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.\relax }}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{4}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.9}Project Rev A Complete}{7}} diff --git a/60hz_Divider/docs/20.log b/60hz_Divider/docs/20.log new file mode 100644 index 0000000..94ee86b --- /dev/null +++ b/60hz_Divider/docs/20.log @@ -0,0 +1,310 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 24 AUG 2020 02:05 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +60hz_Divider/docs/20.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/6 +0hz_Divider/docs/20.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./20.aux) +\openout1 = `20.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +(./20.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 2. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 2. +) +\tf@toc=\write3 +\openout3 = `20.toc'. + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 24. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 24. + <../pics/DSCN2964.JPG, id=1, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2964.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2964.JPG used on input line 26. +(pdftex.def) Requested size: 150.556pt x 112.91699pt. + [1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} <../pics/DSCN2964.JPG>] +Overfull \hbox (88.69052pt too wide) in paragraph at lines 65--65 +[] \OT1/cmtt/m/n/10.95 ***** These pin numbers will probably not work with your + hardware *****[] + [] + +[2] <../pics/DSCN2958.JPG, id=17, 1003.75pt x 752.8125pt> +File: ../pics/DSCN2958.JPG Graphic file (type jpg) + + +Package pdftex.def Info: ../pics/DSCN2958.JPG used on input line 88. +(pdftex.def) Requested size: 200.74644pt x 150.55983pt. + [3] [4 <../pics/DSCN2958.JPG>] [5] +Overfull \hbox (13.65749pt too wide) in paragraph at lines 129--130 +\OT1/cmr/m/n/10.95 Reference: http://maxembedded.com/2011/06/port-operations-in +-avr/ + [] + + +Overfull \hbox (19.70627pt too wide) in paragraph at lines 172--172 +[]\OT1/cmtt/m/n/10.95 //https://playground.arduino.cc/Main/LedControl/#Seg7Cont +rol[] + [] + +[6] +LaTeX Font Info: Try loading font information for OMS+cmr on input line 181. + + (/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd +File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions +) +LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available +(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 181. + [7] [8] (./20.aux) ) +Here is how much of TeX's memory you used: + 3545 strings out of 494945 + 53855 string characters out of 6181032 + 119035 words of memory out of 5000000 + 6815 multiletter control sequences out of 15000+600000 + 8977 words of font info for 32 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,39p,694b,267s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 20.pdf (8 pages, 499780 bytes). +PDF statistics: + 65 PDF objects out of 1000 (max. 8388607) + 44 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 11 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/60hz_Divider/docs/20.pdf b/60hz_Divider/docs/20.pdf new file mode 100644 index 0000000..5072e80 Binary files /dev/null and b/60hz_Divider/docs/20.pdf differ diff --git a/60hz_Divider/docs/20.tex b/60hz_Divider/docs/20.tex new file mode 100644 index 0000000..52047fd --- /dev/null +++ b/60hz_Divider/docs/20.tex @@ -0,0 +1,195 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations on the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +Back to the 14 bit stream... + +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. \footnote{I didn't want to deal with coding the UART into the CPLD. There are also size limitations.} + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. I do have a start bit, and I am not outputting all the time, so this will be one 14 bit value every second. + +\textbf{Problems:} The Uno's digitalRead timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. e.g. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\subsection{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +It turns out that 4 digits on the display is the minimum for a project like this to be viable. 3 digits wouldn't be enough resolution, and 5 digits is not necessary (although nice). The values differ here from about 5996 to 6003 cycles per second. + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + +%todo insert picture + +\end{document} + diff --git a/60hz_Divider/docs/20.tex~ b/60hz_Divider/docs/20.tex~ new file mode 100644 index 0000000..5defbdb --- /dev/null +++ b/60hz_Divider/docs/20.tex~ @@ -0,0 +1,195 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{}} +\author{Steak Electronics} +\date{} +\begin{document} + +%\maketitle + +\tableofcontents +\textcolor{green!60!blue!70}{ + \section{60Hz Divider}} + + +\subsection{Overview} +Let's count. There is a schematic in Practical Electronics For Beginners 4th edition. I've built that up, and will add some CPLD counter logic, along with a micro to output the SPI to a 7seg counter module. + +The goal is relative accuracy. Not absolute. No GPS here. I'm going from 60 to 6,000 cycles.\footnote{Due to limitations of CPLD} This is just meant to be fun. +\begin{center} +\includegraphics[scale=0.15]{../pics/DSCN2964.JPG} +\captionof{figure}{60 Hz Logic Divider to 1Hz} +\end{center} + + +\subsection{Initial Notes: Counting the Hz} +pseudo code goal: +\begin{verbatim} +Using 1Hz signal +Start counting 1MHz every 1Hz +when next cycle is received, + display count + start counting again +\end{verbatim} +That's all the objective is here. Easy with a micro, but goal is to complete using cmos or 74 logic. + + 4553 x 5 + 74hct132 + 1MHz clock (or 6MHz clock), or some variation thereof + jk flip flop + 74376 - quad jk flip flop + 7476 - jk flip flop +1mhz clk will be main counter, +6 hz or 1 hz will be latch / reset + +I ended up skipping the 74 CMOS, in favor of a CPLD. Practical Electronics also mentions this approach as favored. Even a micro alone could be used. Schematic entry in the CPLD could also be used. + +\subsection{MAX7219 8 digit 7 LED segment Display Driver} +Basic code tested with this was the LedControl arduino library. + +\begin{verbatim} +/* + Now we need a LedControl to work with. + ***** These pin numbers will probably not work with your hardware ***** + pin 12 is connected to the DataIn + pin 11 is connected to the CLK + pin 10 is connected to LOAD + We have only a single MAX72XX. + */ +\end{verbatim} +Some of the lines have to be edited to allow for all digits to be read, and +also to lower intensity of display. I think also a component package (dark +grey clear plastic bag) in front of the leds with intensity 1 is about right. + + +\subsection{CPLD Programming} +Using the XC9500XL series. This chip has some limitations - which are good. + +As you get faster clocks, you need bigger registers to handle parsing the clocks. Bigger registers, use more power. Maybe this is one reason why high clock speeds mean more power. + +\subsubsection{6KHz clock} +Due to limitations on the XC9500XL FPGA logic blocks, I ended up limiting the counter registers to 12+1 bits\footnote{Possibly I could use multiple smaller registers in a type of cascade, but let's not bother with that for now. I had 600KHz resolution, until I added the UART out/}, so I have around 6,000 (assuming 60Hz), resolution. With this, I need a 6KHz clock. I could do this with the uno, but let's throw an attiny in there because it's a good tool for this kind of purpose and resolution. It should be able to function as a rough 6KHz timer, easily. + +\subsubsection{UART output} +I set the CPLD to use the rising edge of the 6KHz clock and to shift the counter value out... Unsuprisingly, the baud rate is 6000. I found this by using my Open Bench Logic Sniffer\footnote{Phantom 3 in Repairs 2019}. It's fairly quick to configure and get working. Auto detected the UART speed easy. + +However, my uart value is 12 - 14 bits, and with uart being an 8 bit protocol, it makes this unconventional. May need to bit bang something. But before that... + + +\subsection{Divide by N Counters} + +\begin{center} +\includegraphics[scale=0.2]{../pics/DSCN2958.JPG} +\captionof{figure}{This divide by 6 counter, appears to not line up with what the TTL Cookbook has for a similar 7490 one.} +\end{center} + +The schematics appear to be incorrect for the divide by 6 counter in the Practical Electronics for Beginners book. Having looked at my built up circuit carefully, I see a 20Hz output from the 60Hz. I managed to get my hands on a copy of the TTL Cookbook by Don Lancaster recently, and that details correct divide by 6 and 10 counters (which are different from what's on my proto board), and while I could fix the divide by 6 counter, instead, I'm going to build another divide by 2 counter, and leave the original incorrect one there as a warning (it's also easier to just build a new one). + +As it is, I'm getting 2Hz output on the pulse pin... Oops. Practical Untested Electronics for Beginners. Hax. Everything in life is hax. The earlier you realize that, the better you will feel about your own work.\footnote{It's possible they put the error in on purpose. It's really hard to tell...} + + +\subsection{Attiny 6KHz Clock} +A small victory here: I setup an Attiny10 with an external oscillator (programmable CMOS, not Quartz) of 1.536MHz. I then set prescaler at 256 to get +6000. Set micro fuse to enable CKOUT pin, and now I have a 6KHz clock from the 20 cent micro plus. Neat usage of the attiny10 here, thanks +to my other project using it. The CPLD works with it, no problem. + +\subsection{Parsing of CPLD UART Stream} +Back to the 14 bit stream... + +I have the UART stream feeding into the Atmega328/Uno. For the code, I was unsure how to handle it at first, but then I realized a simple shift in would fit. + +\textbf{Situation:} I have a serial UART stream at 6000 baud from the CPLD. However, it's not exactly UART. In fact, it has values of 6000, which are over 8 bit. So I have a 14 bit serial stream. There is no stop bit after the 8 bits, and no two 8 bit bytes. So hardware serial will not work. \footnote{I didn't want to deal with coding the UART into the CPLD. There are also size limitations.} + +\textbf{Solution:} I have a serial 14 bit stream at 6000 baud. The answer is to tie the 6000 Hz CLK to a pin on the Uno, and implement a shift in, so that every clock up, the value is read on the Serial / 14 bit pin. I do have a start bit, and I am not outputting all the time, so this will be one 14 bit value every second. + +\textbf{Problems:} The Uno's digitalRead timing is not 100\% As a result, some values are being read incorrectly. 5996 shows up as 5048 or similar. I need to go back and access the Input direct via register reads to speed things up. A Pin register access similar to: + +\begin{verbatim} +Example Code Snippet + +Let's demonstrate the use of the DDRx, +PORTx and PINx registers from the + following code snippet: + +DDRC = 0x0F; +PORTC = 0x0C; + +// lets assume a 4V supply comes to PORTC.6 and Vcc = 5V +if (PINC == 0b01000000) + PORTC = 0x0B; +else + PORTC = 0x00; +\end{verbatim} +Reference: http://maxembedded.com/2011/06/port-operations-in-avr/ + + +may fix these issues. In the meantime, because the errors are consistent, I setup some LUTs\footnote{Lookup tables, i.e. hard coded fixes. e.g. 5048 now converts to 5996.}. +\subsection{Max7219 8 digit 7-Segment Display via Uno} +I didn't have any trouble getting the 7 segment to display with the Uno and the Max7219. Note that I avoided outputting the values via the CPLD. The Uno is just quicker to code this output. I used the LedControl library. I had to adopt a quick function to break down the values. The Max7219 does not take in variables, so instead, you feed it single digits. Therefore I needed to extract a single digit from the tens, hundreds, and thousands. See below: + +\begin{verbatim} +//https://playground.arduino.cc/Main/LedControl/#Seg7Control +void printNumber(int v) { + int ones; + int tens; + int hundreds; + int thousands; + boolean negative; + + if(v < -9999 || v > 9999) + return; + if(v<0) { + negative=true; + v=v*-1; + } + ones=v%10; + v=v/10; + tens=v%10; + v=v/10; + hundreds=v%10; + v=v/10; + thousands=v; + /*if(negative) { + //print character '-' in the leftmost column + lc.setChar(0,4,'-',false); + } + else { + //print a blank in the sign column + lc.setChar(0,4,' ',false); + }*/ + //Now print the number digit by digit + lc.setDigit(0,3,(byte)thousands,false); + lc.setDigit(0,2,(byte)hundreds,false); + lc.setDigit(0,1,(byte)tens,false); + lc.setDigit(0,0,(byte)ones,false); +} +\end{verbatim} +Note that I commented out the negative sign on this. My values are always positive. + + + +\subsection{Project Rev A Complete} +With the above complete, I have an initial prototype. The issues with this are the following: + +\begin{itemize} +\item Uno reads 14 bit serial stream wrong (timing issues) +\item 7 segment display slightly bright + \item Should add readout of 120 Volts (can get from transformer) + \item Plywood should be replaced with fiberglass +\end{itemize} + +It turns out that 4 digits on the display is the minimum for a project like this to be viable. 3 digits wouldn't be enough resolution, and 5 digits is not necessary (although nice). The values differ here from about 5996 to 6003 cycles per second. + +Other than that, it is working, and will be setup and watched for a bit to enjoy the readout. + + + + +\end{document} + diff --git a/60hz_Divider/docs/20.toc b/60hz_Divider/docs/20.toc new file mode 100644 index 0000000..ca0f002 --- /dev/null +++ b/60hz_Divider/docs/20.toc @@ -0,0 +1,12 @@ +\contentsline {section}{\numberline {1}60Hz Divider}{1} +\contentsline {subsection}{\numberline {1.1}Overview}{1} +\contentsline {subsection}{\numberline {1.2}Initial Notes: Counting the Hz}{2} +\contentsline {subsection}{\numberline {1.3}MAX7219 8 digit 7 LED segment Display Driver}{2} +\contentsline {subsection}{\numberline {1.4}CPLD Programming}{3} +\contentsline {subsubsection}{\numberline {1.4.1}6KHz clock}{3} +\contentsline {subsubsection}{\numberline {1.4.2}UART output}{3} +\contentsline {subsection}{\numberline {1.5}Divide by N Counters}{4} +\contentsline {subsection}{\numberline {1.6}Attiny 6KHz Clock}{4} +\contentsline {subsection}{\numberline {1.7}Parsing of CPLD UART Stream}{5} +\contentsline {subsection}{\numberline {1.8}Max7219 8 digit 7-Segment Display via Uno}{6} +\contentsline {subsection}{\numberline {1.9}Project Rev A Complete}{7} diff --git a/Log_Viewer/docs/5.log b/Log_Viewer/docs/5.log index fc43772..38ab5d1 100644 --- a/Log_Viewer/docs/5.log +++ b/Log_Viewer/docs/5.log @@ -1,4 +1,4 @@ -This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 12 JUN 2020 02:29 +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 12 AUG 2020 11:30 entering extended mode restricted \write18 enabled. %&-line parsing enabled. diff --git a/Log_Viewer/docs/5.pdf b/Log_Viewer/docs/5.pdf index 6b41190..37157cc 100644 Binary files a/Log_Viewer/docs/5.pdf and b/Log_Viewer/docs/5.pdf differ diff --git a/Log_Viewer/docs/6.aux b/Log_Viewer/docs/6.aux new file mode 100644 index 0000000..e3487c0 --- /dev/null +++ b/Log_Viewer/docs/6.aux @@ -0,0 +1,6 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}Log Viewer}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}LM317}{1}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Power Board}{2}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.1}Video Output Modes}{2}} +\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}Misc Notes}{3}} diff --git a/Log_Viewer/docs/6.log b/Log_Viewer/docs/6.log new file mode 100644 index 0000000..3397869 --- /dev/null +++ b/Log_Viewer/docs/6.log @@ -0,0 +1,329 @@ +This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex 2019.8.17) 12 AUG 2020 11:31 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/ +Log_Viewer/docs/6.tex + +(/home/layoutdev/Desktop/code/documentation_general/Electronics_Projects_2020/L +og_Viewer/docs/6.tex +LaTeX2e <2017/01/01> patch level 3 +Babel <3.9r> and hyphenation patterns for 3 language(s) loaded. +(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls +Document Class: article 2014/09/29 v1.4h Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo +File: size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option) +) +\c@part=\count79 +\c@section=\count80 +\c@subsection=\count81 +\c@subsubsection=\count82 +\c@paragraph=\count83 +\c@subparagraph=\count84 +\c@figure=\count85 +\c@table=\count86 +\abovecaptionskip=\skip41 +\belowcaptionskip=\skip42 +\bibindent=\dimen102 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty +Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty +Package: keyval 2014/10/28 v1.15 key=value parser (DPC) +\KV@toks@=\toks14 +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty +Package: graphics 2016/10/09 v1.0u Standard LaTeX Graphics (DPC,SPQR) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty +Package: trig 2016/01/03 v1.10 sin cos tan (DPC) +) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg +File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration +) +Package graphics Info: Driver file: pdftex.def on input line 99. + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def +File: pdftex.def 2017/01/12 v0.06k Graphics/color for pdfTeX + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty +Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO) +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty +Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO) +) +\Gread@gobject=\count87 +)) +\Gin@req@height=\dimen103 +\Gin@req@width=\dimen104 +) +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty +Package: caption 2016/02/21 v3.3-144 Customizing captions (AR) + +(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty +Package: caption3 2016/05/22 v1.7-166 caption3 kernel (AR) +Package caption3 Info: TeX engine: e-TeX on input line 67. +\captionmargin=\dimen105 +\captionmargin@=\dimen106 +\captionwidth=\dimen107 +\caption@tempdima=\dimen108 +\caption@indent=\dimen109 +\caption@parindent=\dimen110 +\caption@hangindent=\dimen111 +) +\c@ContinuedFloat=\count88 +) +(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty +Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK) + +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg +File: color.cfg 2016/01/02 v1.6 sample color configuration +) +Package xcolor Info: Driver file: pdftex.def on input line 225. +Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348. +Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352. +Package xcolor Info: Model `RGB' extended on input line 1364. +Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366. +Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367. +Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368. +Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369. +Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370. +Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371. +) +(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty +Package: geometry 2010/09/12 v5.6 Page Geometry + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty +Package: ifpdf 2016/05/14 v3.1 Provides the ifpdf switch +) +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty +Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO) +Package ifvtex Info: VTeX not detected. +) +(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty +Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional +) +\Gm@cnth=\count89 +\Gm@cntv=\count90 +\c@Gm@tempcnt=\count91 +\Gm@bindingoffset=\dimen112 +\Gm@wd@mp=\dimen113 +\Gm@odd@mp=\dimen114 +\Gm@even@mp=\dimen115 +\Gm@layoutwidth=\dimen116 +\Gm@layoutheight=\dimen117 +\Gm@layouthoffset=\dimen118 +\Gm@layoutvoffset=\dimen119 +\Gm@dimlist=\toks15 +) (./6.aux) +\openout1 = `6.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 12. +LaTeX Font Info: ... okay on input line 12. + +(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii +[Loading MPS to PDF converter (version 2006.09.02).] +\scratchcounter=\count92 +\scratchdimen=\dimen120 +\scratchbox=\box26 +\nofMPsegments=\count93 +\nofMParguments=\count94 +\everyMPshowfont=\toks16 +\MPscratchCnt=\count95 +\MPscratchDim=\dimen121 +\MPnumerator=\count96 +\makeMPintoPDFobject=\count97 +\everyMPtoPDFconversion=\toks17 +) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty +Package: pdftexcmds 2016/05/21 v0.22 Utility functions of pdfTeX for LuaTeX (HO +) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty +Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO) +Package ifluatex Info: LuaTeX not detected. +) +Package pdftexcmds Info: LuaTeX not detected. +Package pdftexcmds Info: \pdf@primitive is available. +Package pdftexcmds Info: \pdf@ifprimitive is available. +Package pdftexcmds Info: \pdfdraftmode found. +) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty +Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf + +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty +Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty +Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO) +)) +(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty +Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty +Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO) + +(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty +Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO) +Package etexcmds Info: Could not find \expanded. +(etexcmds) That can mean that you are not using pdfTeX 1.50 or +(etexcmds) that some package has redefined \expanded. +(etexcmds) In the latter case, load this package earlier. +))) +Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 +38. +Package grfext Info: Graphics extension search list: +(grfext) [.png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPE +G,.JBIG2,.JB2,.eps] +(grfext) \AppendGraphicsExtensions on input line 456. + +(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg +File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv +e +)) +Package caption Info: Begin \AtBeginDocument code. +Package caption Info: End \AtBeginDocument code. + +*geometry* detected driver: dvips +*geometry* verbose mode - [ preamble ] result: +* driver: dvips +* paper: custom +* layout: +* layoutoffset:(h,v)=(0.0pt,0.0pt) +* vratio: 1:1 +* modes: +* h-part:(L,W,R)=(54.2025pt, 325.215pt, 54.2025pt) +* v-part:(T,H,B)=(79.49689pt, 491.43622pt, 79.49689pt) +* \paperwidth=433.62pt +* \paperheight=650.43pt +* \textwidth=325.215pt +* \textheight=491.43622pt +* \oddsidemargin=-18.06749pt +* \evensidemargin=-18.06749pt +* \topmargin=-29.7731pt +* \headheight=12.0pt +* \headsep=25.0pt +* \topskip=11.0pt +* \footskip=30.0pt +* \marginparwidth=59.0pt +* \marginparsep=10.0pt +* \columnsep=10.0pt +* \skip\footins=10.0pt plus 4.0pt minus 2.0pt +* \hoffset=0.0pt +* \voffset=0.0pt +* \mag=1000 +* \@twocolumnfalse +* \@twosidefalse +* \@mparswitchfalse +* \@reversemarginfalse +* (1in=72.27pt=25.4mm, 1cm=28.453pt) + +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <12> on input line 14. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line 14. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line 14. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <10.95> on input line 36. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <9> on input line 36. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 36. + +Underfull \hbox (badness 10000) in paragraph at lines 36--40 + + [] + +[1 +Non-PDF special ignored! + +{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] +Overfull \hbox (136.08179pt too wide) in paragraph at lines 61--64 +[]\OT1/cmr/m/n/10.95 These look like the so-lu-tion https://raspberrypi.stackex +change.com/questions/50220/connect- + [] + + +Overfull \hbox (68.8029pt too wide) in paragraph at lines 61--64 +\OT1/cmr/m/n/10.95 the-tty1-screen-to-my-ssh-session https://www.linuxquestions +.org/questions/linux- + [] + +[2] +Overfull \hbox (226.65903pt too wide) in paragraph at lines 88--88 +[]\OT1/cmtt/m/n/10.95 1. dl and view logs, rotate through logs by pressing swit +ches (for page down), just cat all logs[] + [] + + +Overfull \hbox (249.65378pt too wide) in paragraph at lines 88--88 +[] \OT1/cmtt/m/n/10.95 in folder. (EDIT: less requires two key presses to ge +t to next page (:n), so use more (not less)[] + [] + + +Overfull \hbox (19.70627pt too wide) in paragraph at lines 88--88 +[]\OT1/cmtt/m/n/10.95 2. view irc chat (will need to be connected, so tmux atta +ch,[] + [] + + +Overfull \hbox (128.93134pt too wide) in paragraph at lines 88--88 +[] \OT1/cmtt/m/n/10.95 then use other switches on matrix, to change to next +irc chatroom) (ctrl-n)[] + [] + + +Overfull \hbox (71.44446pt too wide) in paragraph at lines 88--88 +[]\OT1/cmtt/m/n/10.95 usb to ethernet, bb, svideo to svideo to viewfinder, swit +ches, etc...[] + [] + + +Overfull \hbox (71.44446pt too wide) in paragraph at lines 88--88 +[] \OT1/cmtt/m/n/10.95 0.1 copy existing bb devuan sd to new img, and new sd + card - DONE[] + [] + + +Overfull \hbox (220.91034pt too wide) in paragraph at lines 88--88 +[] \OT1/cmtt/m/n/10.95 0.2 lm317 for 7v supply to crt viewfinder. (note: on +semi lm317 had smaller to220 tab) DONE[] + [] + +[3] (./6.aux) ) +Here is how much of TeX's memory you used: + 3519 strings out of 494945 + 53364 string characters out of 6181032 + 118045 words of memory out of 5000000 + 6796 multiletter control sequences out of 15000+600000 + 10544 words of font info for 37 fonts, out of 8000000 for 9000 + 14 hyphenation exceptions out of 8191 + 39i,8n,38p,575b,189s stack positions out of 5000i,500n,10000p,200000b,80000s + +Output written on 6.pdf (3 pages, 123739 bytes). +PDF statistics: + 50 PDF objects out of 1000 (max. 8388607) + 35 compressed objects within 1 object stream + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000) + diff --git a/Log_Viewer/docs/6.pdf b/Log_Viewer/docs/6.pdf new file mode 100644 index 0000000..a2213b6 Binary files /dev/null and b/Log_Viewer/docs/6.pdf differ diff --git a/Log_Viewer/docs/6.tex b/Log_Viewer/docs/6.tex new file mode 100644 index 0000000..c9de9c0 --- /dev/null +++ b/Log_Viewer/docs/6.tex @@ -0,0 +1,91 @@ + +\documentclass[11pt]{article} +%Gummi|065|=) +\usepackage{graphicx} +\usepackage{caption} +\usepackage{xcolor} +\usepackage[vcentering,dvips]{geometry} +\geometry{papersize={6in,9in},total={4.5in,6.8in}} +\title{\textbf{Log Viewer}} +\author{Steak Electronics} +\date{} +\begin{document} + +\maketitle + +%\tableofcontents +\textcolor{green!60!blue!70}{ + \section{Log Viewer}} + + +\subsection{LM317} +As the viewfinder needs its own power supply, I need 7V from 12V. Parts box has LM317. + +\begin{verbatim} +Formula for LM317: + Vout = 1.25 * (1+ R2/R1) + + R1 = vout to gndpin + R2 = gndpin to gnd + + e.g. 720 R2, 240 R1 == 5V + 1K R2 == 6.45V + 1.1K R2 == 6.97V + +\end{verbatim} +\textbf{Standard R1 is 240ohm}, so let's keep to the standard.\footnote{Check when looking through devices that use LM317, which adhere to that standard. They should, when possible. Standards should always be followed.} +\\ +\\ +Make sure to \underline{account for the drop out} needed for Vin to LM317. + + + +\textcolor{green!60!blue!70}{ + \subsection{Power Board}} +\emph{Cutting dip switches in half, because they don't sell smaller than arrays of 4.} + + +I built an adapter board. LM317, with svideo out signal split. There are two signals on svideo, and two grounds. The signals, can be viewed in a scope. Y and C. One is video (Y - Luminance and Sync). The other, doesn't look like ntsc video (chroma), and is put in series w/470pf cap to the video signal. Be careful that the picture is of the male connector, not female. Review signals in scope to be sure. If you get it backwards, as I did, it probably won't break anything. +\footnote{Ref: https://www.linuxtv.org/wiki/index.php/Composite\_to\_S-Video} + +\textcolor{green!60!blue!70}{ +\subsubsection{Video Output Modes}} +At this point, with the Beagleboard, I have video outputting to the CRT but not at the right resolution. Hwinfo --framebuffer is empty on beagleboard (when X is not running). Seems the fb is not enabled. + +I looked at a lot of information. There are some sources advising changing kernel flags (touchy, may cause failure to boot), i.e. vga=\#\#\# where number is a reference to the resolution (there is a LUT, it's not 1:1). However none of that looked like the right path... + +The man page of console-setup explains, different fonts have different font sizes. I tried the largest FIXED font at first, but it wasn't enough. After reading the man, I changed to TerminusBold, which had larger fonts. This seems to work.\footnote{Edges of screen are still a bit hard to see in crt. I will look for a work around once I'm logged in.} + +One thing, my main keyboard doesn't work on the bb (via usb A). Need a different one. Instead, I should change from the ssh'd terminal to the svideo. Magic search term here is maybe: ``linux ssh to local tty'' Appears that screen (for existing logged in sessions) or linuxvnc is an option. Might be difficult if I'm not already logged in. EDIT: linuxvnc is obsolete. + +These look like the solution +https://raspberrypi.stackexchange.com/questions/50220/connect-the-tty1-screen-to-my-ssh-session +https://www.linuxquestions.org/questions/linux-general-1/ssh-to-local-console-tty-576349/ + +It's something I've already done: have user auto logged in, then jump onto the session afterwards. Easy. + +\subsection{Misc Notes} +\begin{verbatim} +switch matrix via usb, bb, viewfinder. +hit switch, it changes modes, lights LED +different modes for e.g. +1. dl and view logs, rotate through logs by pressing switches (for page down), just cat all logs + in folder. (EDIT: less requires two key presses to get to next page (:n), so use more (not less) + , and hit space bar) +2. view irc chat (will need to be connected, so tmux attach, + then use other switches on matrix, to change to next irc chatroom) (ctrl-n) +3. ???? + +usb to ethernet, bb, svideo to svideo to viewfinder, switches, etc... +start small: + + 0. expand size of layoutdev hdd - DONE + 0.1 copy existing bb devuan sd to new img, and new sd card - DONE + 0.2 lm317 for 7v supply to crt viewfinder. (note: on semi lm317 had smaller to220 tab) DONE + 1. bb to viewfinder. DONE + 2. boot into session + 3. have session w/different scripts that can run +\end{verbatim} + +\end{document} +