Browse Source

countersunk

master
Your Name 3 years ago
parent
commit
a52cc16a10
5 changed files with 571 additions and 0 deletions
  1. +7
    -0
      UserSpaceArduinoUno_via_Ulisp/docs/9.aux
  2. +305
    -0
      UserSpaceArduinoUno_via_Ulisp/docs/9.log
  3. BIN
      UserSpaceArduinoUno_via_Ulisp/docs/9.pdf
  4. +138
    -0
      UserSpaceArduinoUno_via_Ulisp/docs/9.tex
  5. +121
    -0
      UserSpaceArduinoUno_via_Ulisp/docs/9.tex~

+ 7
- 0
UserSpaceArduinoUno_via_Ulisp/docs/9.aux View File

@ -0,0 +1,7 @@
\relax
\@writefile{toc}{\contentsline {section}{\numberline {1}UserSpace IO via uLisp and Arduino Uno}{1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Setup}{1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.1.1}Trouble with interfacing directly to ttyACM0}{1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.1.2}Troubleshooting Code}{2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}An interface for basic GPIO}{3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.3}Countersunk Magnets}{4}\protected@file@percent }

+ 305
- 0
UserSpaceArduinoUno_via_Ulisp/docs/9.log View File

@ -0,0 +1,305 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex 2021.1.4) 3 MAR 2021 03:25
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**/home/dev/Desktop/code/Electronics_Projects_2021/UserSpaceArduinoUno_via_Ulis
p/docs/9.tex
(/home/dev/Desktop/code/Electronics_Projects_2021/UserSpaceArduinoUno_via_Ulisp
/docs/9.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo
File: size11.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2017/06/01 v1.1a 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 2017/06/25 v1.2c 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 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen103
\Gin@req@width=\dimen104
)
(/usr/share/texlive/texmf-dist/tex/latex/caption/caption.sty
Package: caption 2018/10/06 v3.3-154 Customizing captions (AR)
(/usr/share/texlive/texmf-dist/tex/latex/caption/caption3.sty
Package: caption3 2018/09/12 v1.8c caption3 kernel (AR)
Package caption3 Info: TeX engine: e-TeX on input line 64.
\captionmargin=\dimen105
\captionmargin@=\dimen106
\captionwidth=\dimen107
\caption@tempdima=\dimen108
\caption@indent=\dimen109
\caption@parindent=\dimen110
\caption@hangindent=\dimen111
)
\c@caption@flags=\count88
\c@ContinuedFloat=\count89
)
(/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 2018/04/16 v5.8 Page Geometry
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2018/09/07 v3.3 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=\count90
\Gm@cntv=\count91
\c@Gm@tempcnt=\count92
\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
) (./9.aux)
\openout1 = `9.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=\count93
\scratchdimen=\dimen120
\scratchbox=\box27
\nofMPsegments=\count94
\nofMParguments=\count95
\everyMPshowfont=\toks16
\MPscratchCnt=\count96
\MPscratchDim=\dimen121
\MPnumerator=\count97
\makeMPintoPDFobject=\count98
\everyMPtoPDFconversion=\toks17
) (/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/generic/oberdiek/infwarerr.sty
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
(/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/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (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)
(/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.
))))
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
Package: pdftexcmds 2018/09/10 v0.29 Utility functions of pdfTeX for LuaTeX (HO
)
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.
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.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: <same size as paper>
* 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: Try loading font information for OML+cmr on input line 19.
(/usr/share/texlive/texmf-dist/tex/latex/base/omlcmr.fd
File: omlcmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: Font shape `OML/cmr/m/n' in size <10.95> not available
(Font) Font shape `OML/cmm/m/it' tried instead on input line 19.
Underfull \hbox (badness 10000) in paragraph at lines 23--25
[]
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <10.95> on input line 28.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <9> on input line 28.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 28.
[1
Non-PDF special ignored!
<special> papersize=433.62pt,650.43pt
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
Overfull \hbox (24.20909pt too wide) in paragraph at lines 46--47
[]\OT1/cmr/m/n/10.95 https://arduino.stackexchange.com/questions/16776/how-to-c
onnect-
[]
Overfull \hbox (6.41527pt too wide) in paragraph at lines 48--49
[]\OT1/cmr/m/n/10.95 https://stackoverflow.com/questions/3918032/bash-serial-i-
o-and-
[]
[2]
Overfull \hbox (2.4602pt too wide) in paragraph at lines 115--115
[] \OT1/cmtt/m/n/10.95 answer: I want to be able to flash leds from user space.
[]
[]
[3]
Overfull \hbox (19.70627pt too wide) in paragraph at lines 115--115
[] \OT1/cmtt/m/n/10.95 solution: build box / board for uno. connect everything
up.[]
[]
Overfull \hbox (25.45496pt too wide) in paragraph at lines 115--115
[] \OT1/cmtt/m/n/10.95 Then find a way to send commands from gnulinux. let's be
gin.[]
[]
[4] [5] (./9.aux) )
Here is how much of TeX's memory you used:
3528 strings out of 494561
53599 string characters out of 6177455
123326 words of memory out of 5000000
7170 multiletter control sequences out of 15000+600000
10198 words of font info for 36 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
41i,8n,38p,958b,253s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/c
m/cmbx10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx
12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb
></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/
share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/t
exlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr6.pfb></usr/share/texlive/t
exmf-dist/fonts/type1/public/amsfonts/cm/cmr8.pfb></usr/share/texlive/texmf-dis
t/fonts/type1/public/amsfonts/cm/cmr9.pfb></usr/share/texlive/texmf-dist/fonts/
type1/public/amsfonts/cm/cmtt10.pfb>
Output written on 9.pdf (5 pages, 122216 bytes).
PDF statistics:
56 PDF objects out of 1000 (max. 8388607)
39 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)

BIN
UserSpaceArduinoUno_via_Ulisp/docs/9.pdf View File


+ 138
- 0
UserSpaceArduinoUno_via_Ulisp/docs/9.tex View File

@ -0,0 +1,138 @@
\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{UserSpace IO via uLisp and Arduino Uno}}
\author{Steak Electronics}
\date{}
\begin{document}
\maketitle
%\tableofcontents
\textcolor{green!60!blue!70}{
\section{UserSpace IO via uLisp and Arduino Uno}}
Overview: Goal is to get an easy way to echo "command" \textgreater
/dev/ARDUINO from GnuLinux userspace.
Then I can 3D print a box, throw some LEDs in there, and get a hardware interface for anything from my distro.
\\
\subsection{Setup}
First off, I installed the stable uLisp from ulisp.com (AVR version 3.4 in 2020/12). \footnote{It's a sketch. It installs from Arduino IDE (must be reasonably recent, so 1.8 from Arduino.com works, but not Beowulf/Buster's 1.0 Arduino).}
\subsubsection{Trouble with interfacing directly to
ttyACM0} The Arduino Uno uses an FTDI USB to Serial chip. It also has more than just RX/TX connected (I think). This means
that when you echo "something" to arduino, this command will open the serial connection, send the command, then close the command and
possibly reset the board via one of the UART reset pins (DTS perhaps). This won't work. First thing to do, get an FTDI board, and
connect it to the computer, the connect it to digital pins 0,1 (for UART). Then test sending a command. This works. This will be the
final setup. Computer -\textgreater FTDI -\textgreater Arduino.
It should be possible to get it to work without the FTDI chip, but not without some debugging. Have at it, if you wish. I don't have
time to troubleshoot this now. I tried a few things (exec 3\textless \textgreater, and the stty) neither worked. You could also use Python, but then that's
more dependencies. Bad idea. This should be simple.
Ref:
https://forum.arduino.cc/index.php?topic=61127.0
https://arduino.stackexchange.com/questions/16776/how-to-connect-arduino-device-to-linux
https://stackoverflow.com/questions/3918032/bash-serial-i-o-and-arduino
\subsubsection{Troubleshooting Code}
The first thing you will want to do is prove that you can echo or cat "code" \textgreater /dev/ARDUINO.
This code works:
\begin{verbatim}
(defun b (&optional x)
(pinmode 13 :output)
(digitalwrite 13 x)
(delay 1000)
(b (not x)))
(b)
\end{verbatim}
Save it as a text file, then cat the file into /dev/ttyUSB0 or /dev/ARDUINO. Problem is, the code runs
indefinitely. You can't tell it to do anything else. Hit the reset button to restart the Uno back to square one. So instead, you want a
function that runs and then stops. Here's one of those:
\begin{verbatim} (defun b ()
(pinmode 13 :output)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200))
(b)
\end{verbatim}
This works. Save it as a .dat or .txt (whatever) and cat file.txt \textgreater /dev/ARDUINO. It will blink a few times, then
stop. You can cat it again, if you wish. There, now we have an interface, and we have proven we can switch an IO high/low. With a couple
of functions, it's trivial to build an interface.\footnote{i.e. have one function set IO high for a given pin. Have one function set IO low.
Have one function blink IO some amount of times. This can be used for counters or shift registers, or in the former, just controlling GPIO.}
Tip: When building code, copy and paste into the Arduino Serial Monitor first. This way, if there's an error, it will tell you what's
wrong. After you've tested the code, then you can put it in a text file. As we are keeping this simple, we don't have logging setup, or
anything else. This is meant to be for basic IO from user space, not C compiled programs. Think lightweight. Fast. Fun.
\subsection{An interface for basic GPIO}
Now, let's build an API/interface so that we can flip some IO, and perhaps increment as mentioned.
\begin{verbatim}
let's ask this: what do I want to accomplish?
answer: I want to be able to flash leds from user space.
possibly increment a counter, but
that's later. for now, just flash leds.
solution: build box / board for uno. connect everything up.
build initialization program
(that will enable outputs as high)
Then find a way to send commands from gnulinux. let's begin.
1. build initialization program
2. create enclosure, and wire up leds
3. run program live from gnuLinux.
\end{verbatim}
--
\subsection{Countersunk Magnets}
This is a bit of a sidestory from another project, but since I'm already putting 2020's electronics projects into a book, I can't edit those documents. In 2020, I have a project that covers Attiny10 protoboard and setup. The goal is a wireless sensor. In 2020 I also toredown an Edimax Wireless AP. What is notable is that the WAP had countersunk magnets. Countersunk is essentially that there is a hole in the magnet for a screw to go \footnote{This is an oversimplification, as there is also counterbore, which is similar to countersunking but without the gradient according to wikipedia, but for our practical intents and purposes, countersunk magnet means, ``screw hole in middle where you can attach somewhere''. That's the term that it represents online in stores. If I had time, I'd put a picture of a countersunk magnet on the wiki page.}.
This term refers to both the rectangular pieces you would screw into drywall or concrete, and also to the circular pieces that you would put into your enclosure/box. Looking at the WAP1750 design, you simply put a hole on the bottom of the box, for a threaded insert, use an iron to attach the threaded insert quickly, then screw the magnet into the insert. I see a lot of 3mm countersunk magnets, so either \#4 or 3mm screws can be used.
Prices are reasonable, but not free. I see a pack of 50 qty. countersunk magnets for about \$6.50. That's close to 10 cents per magnet. My boxes will use two, so that's about 25 cents for these magnets per box. These are industrial sensors, so I think it's acceptable.
However, the rectangular parts are more expensive. These look to be about \$2 each minimum. More research needed.
Why use magnets to mount your box to the wall? It makes removal and maintenace of the box much, MUCH easier. There is no going back. No more screwing to the wall, and you don't even have to remove it from a bracket. If you can put magnets in your device without interfering with the circuitry, I think it's an obvious choice.
Some other products / cameras use this. During my search I found for example, the Netgear Arlo that has a rounded magnet mount for its camera. The camera can be adjusted anywhere in a 180 degree radius around the round mount. This is not necessary for the application that I'm using, but it's a novel idea. The mounts are available online, at about \$7 each. Ouch.
So if price is an issue, you use a cheap plastic bracket, and screw the bracket into the drywall / concrete, place the box in the bracket. But magnets, are much more functional, if you can get them, and they don't interfere.\footnote{They'll even allow attaching the wireless battery powered sensors to anything that is magnetic metal. That saves the need for the rectangular part, but make sure you get the poles right.}
%pictures of wap mounts
\end{document}

+ 121
- 0
UserSpaceArduinoUno_via_Ulisp/docs/9.tex~ View File

@ -0,0 +1,121 @@
\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{UserSpace IO via uLisp and Arduino Uno}}
\author{Steak Electronics}
\date{}
\begin{document}
\maketitle
%\tableofcontents
\textcolor{green!60!blue!70}{
\section{UserSpace IO via uLisp and Arduino Uno}}
Overview: Goal is to get an easy way to echo "command" \textgreater
/dev/ARDUINO from GnuLinux userspace.
Then I can 3D print a box, throw some LEDs in there, and get a hardware interface for anything from my distro.
\\
\subsection{Setup}
First off, I installed the stable uLisp from ulisp.com (AVR version 3.4 in 2020/12). \footnote{It's a sketch. It installs from Arduino IDE (must be reasonably recent, so 1.8 from Arduino.com works, but not Beowulf/Buster's 1.0 Arduino).}
\subsubsection{Trouble with interfacing directly to
ttyACM0} The Arduino Uno uses an FTDI USB to Serial chip. It also has more than just RX/TX connected (I think). This means
that when you echo "something" to arduino, this command will open the serial connection, send the command, then close the command and
possibly reset the board via one of the UART reset pins (DTS perhaps). This won't work. First thing to do, get an FTDI board, and
connect it to the computer, the connect it to digital pins 0,1 (for UART). Then test sending a command. This works. This will be the
final setup. Computer -\textgreater FTDI -\textgreater Arduino.
It should be possible to get it to work without the FTDI chip, but not without some debugging. Have at it, if you wish. I don't have
time to troubleshoot this now. I tried a few things (exec 3\textless \textgreater, and the stty) neither worked. You could also use Python, but then that's
more dependencies. Bad idea. This should be simple.
Ref:
https://forum.arduino.cc/index.php?topic=61127.0
https://arduino.stackexchange.com/questions/16776/how-to-connect-arduino-device-to-linux
https://stackoverflow.com/questions/3918032/bash-serial-i-o-and-arduino
\subsubsection{Troubleshooting Code}
The first thing you will want to do is prove that you can echo or cat "code" \textgreater /dev/ARDUINO.
This code works:
\begin{verbatim}
(defun b (&optional x)
(pinmode 13 :output)
(digitalwrite 13 x)
(delay 1000)
(b (not x)))
(b)
\end{verbatim}
Save it as a text file, then cat the file into /dev/ttyUSB0 or /dev/ARDUINO. Problem is, the code runs
indefinitely. You can't tell it to do anything else. Hit the reset button to restart the Uno back to square one. So instead, you want a
function that runs and then stops. Here's one of those:
\begin{verbatim} (defun b ()
(pinmode 13 :output)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200)
(digitalwrite 13 nil)
(delay 500)
(digitalwrite 13 t)
(delay 200))
(b)
\end{verbatim}
This works. Save it as a .dat or .txt (whatever) and cat file.txt \textgreater /dev/ARDUINO. It will blink a few times, then
stop. You can cat it again, if you wish. There, now we have an interface, and we have proven we can switch an IO high/low. With a couple
of functions, it's trivial to build an interface.\footnote{i.e. have one function set IO high for a given pin. Have one function set IO low.
Have one function blink IO some amount of times. This can be used for counters or shift registers, or in the former, just controlling GPIO.}
Tip: When building code, copy and paste into the Arduino Serial Monitor first. This way, if there's an error, it will tell you what's
wrong. After you've tested the code, then you can put it in a text file. As we are keeping this simple, we don't have logging setup, or
anything else. This is meant to be for basic IO from user space, not C compiled programs. Think lightweight. Fast. Fun.
\subsection{An interface for basic GPIO}
Now, let's build an API/interface so that we can flip some IO, and perhaps increment as mentioned.
\begin{verbatim}
let's ask this: what do I want to accomplish?
answer: I want to be able to flash leds from user space.
possibly increment a counter, but
that's later. for now, just flash leds.
solution: build box / board for uno. connect everything up.
build initialization program
(that will enable outputs as high)
Then find a way to send commands from gnulinux. let's begin.
1. build initialization program
2. create enclosure, and wire up leds
3. run program live from gnuLinux.
\end{verbatim}
--
\end{document}

Loading…
Cancel
Save