Linux and Electronics
Urs Lindegger
Linux and Electronics
Urs Lindegger Copyright © 2019-11-25 Urs Lindegger
Table of Contents
- 1. Introduction ..........................................................................................................
- 1
1222
Note ................................................................................................................
2. Printed Circuits ......................................................................................................
Printed Circuit Board design ................................................................................
Kicad ....................................................................................................... Eagle ..................................................................................................... 13
Simulation ...................................................................................................... 13
Spice ..................................................................................................... 13 Digital simulation .................................................................................... 18
Wings 3D ....................................................................................................... 18
User interface .......................................................................................... 19 Modeling ................................................................................................ 19 Making holes in Wings 3D ........................................................................ 20
3. Embedded Devices ............................................................................................... 21
Cross compilation ............................................................................................ 21 distcc ............................................................................................................. 22 Embedded Linux .............................................................................................. 23 x86 embedded ................................................................................................. 23 Raspberry pi ................................................................................................... 24
Gentoo on Raspberry ................................................................................ 25 Debian on Raspberry ................................................................................ 27
Beaglebone ..................................................................................................... 28 Sabre ............................................................................................................. 30
MCIMX6 ................................................................................................ 31 ltib ........................................................................................................ 31 Gentoo Linux on Sabre ............................................................................. 31 Mfgtool .................................................................................................. 36
AVR microcontrollers ....................................................................................... 37
Building Avr crosscompiler under Gentoo Linux ........................................... 37 Setoutput ................................................................................................ 38 Compiling and linking .............................................................................. 38 Program the chip ..................................................................................... 41 Debugging AVR micro controllers .............................................................. 45 Assembler ............................................................................................... 47 Codeblocks ............................................................................................. 48 AVR eclipse plugin .................................................................................. 51 AvrStudio and WinAvr ............................................................................. 55 Arduino .................................................................................................. 55 Interfacing AVR devices to Linux via USB .................................................. 57
PIC microcontrollers ......................................................................................... 57 STM32 ........................................................................................................... 58 C and small microcontrollers ............................................................................. 59 LCDproc ........................................................................................................ 59
Hardware issues ....................................................................................... 59 LCDproc software setup ............................................................................ 61
Modbus .......................................................................................................... 61
Terms and definitions ............................................................................... 61 Libmodbus .............................................................................................. 62 Modbus with Python ................................................................................ 63 Freemodbus ............................................................................................ 63
MBLogic ........................................................................................................ 64
MBLogic Soft Logic ................................................................................ 65 HMIServer .............................................................................................. 65 MBProbe ................................................................................................ 68
4. Interface ............................................................................................................. 69
iv
Linux and Electronics
Serial port ....................................................................................................... 69
Working with serial ports .......................................................................... 69 Terminal programs ................................................................................... 70 Troubleshooting serial links ....................................................................... 71 USB to RS232 serial controller .................................................................. 71 Programming serial links ........................................................................... 72 Connection to a remote serial link ............................................................... 72
I2C ................................................................................................................ 73
External I2C adapters ............................................................................... 73 Observing an external LM75 chip ............................................................... 74 MLX90614 Infra Red Thermometer ............................................................ 76 Observing a memory chip ......................................................................... 76 I2c bit banging ........................................................................................ 77
CAN .............................................................................................................. 79
CAN Hardware ........................................................................................ 79 CAN frames ............................................................................................ 79 CANopen ............................................................................................... 81 CAN Festival .......................................................................................... 82
Bluetooth ........................................................................................................ 83
Inside bluetooth ....................................................................................... 83 Adeunis ARF7678AA ............................................................................... 84 Laird BTM411 ........................................................................................ 84
LIRC ............................................................................................................. 86
LIRC inside ............................................................................................ 86 About the IR signals and the configuration file .............................................. 86 Lirc receivers .......................................................................................... 87 Lirc transmitters ...................................................................................... 87 A homebrew serial LIRC receiver ............................................................... 88 Audio receivers and transmitters ................................................................. 91 UDP ...................................................................................................... 95 UIR, IRman, UIRT, UIRT2 and USB-UIRT ................................................. 95 Setting up and testing the LIRC receiver ...................................................... 97 LIRC troubleshooting ............................................................................... 99 Using v4l2 ir devices under LIRC ............................................................. 100
v
List of Figures
2.1. KiCad schematics ................................................................................................ 2.2. KiCad PCB ........................................................................................................ 2.3. KiCad 3D ..........................................................................................................
689
2.4. kiCad drill ........................................................................................................ 10 2.5. GCprevue ......................................................................................................... 11 2.6. Drill data .......................................................................................................... 12 2.7. gschem ............................................................................................................. 15 2.8. gspiceui ............................................................................................................ 16 2.9. gwave .............................................................................................................. 18 2.10. Wings ............................................................................................................ 18 3.1. Geode .............................................................................................................. 24 3.2. Raspberry PI ..................................................................................................... 25 3.3. Beagle Bone ..................................................................................................... 28 3.4. Sabre ............................................................................................................... 30 3.5. JTAG ICE ........................................................................................................ 44 3.6. Attiny .............................................................................................................. 47 3.7. Codeblocks and AVR dude ................................................................................. 49 3.8. CodeBlocks and avarice ...................................................................................... 50 3.9. AVR Project ..................................................................................................... 52 3.10. avr debug settings ............................................................................................ 54 3.11. Arduino .......................................................................................................... 56 3.12. gpsim ............................................................................................................. 58 3.13. Lcds ............................................................................................................... 60 4.1. Make IR visible ................................................................................................. 86 4.2. IR signals ......................................................................................................... 87 4.3. Lirc serial receiver ............................................................................................. 88 4.4. Component side ................................................................................................. 89 4.5. Solder side ....................................................................................................... 89 4.6. Isolation ........................................................................................................... 89 4.7. Lirco ............................................................................................................... 90 4.8. IR audio schematics ........................................................................................... 92 4.9. IR audio hardware ............................................................................................. 92 4.10. Running into saturation ..................................................................................... 93 4.11. Understandable signal ....................................................................................... 94 4.12. IR Remote controller ........................................................................................ 98
vi
List of Examples
3.1. Compilation Raspberry versus PC ......................................................................... 26 3.2. setoutput .......................................................................................................... 38
vii
Chapter 1. Introduction
Note
http://www.linurs.org/Copyright 2019-11-25 Urs Lindegger Permission to use, copy, modify, distribute, and sell this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation.
THE DOCUMENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, IN NO EVENT SHALL I BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY.
1
Chapter 2. Printed Circuits
Printed Circuit Board design
It was common to use imperial measurement units for printed circuit boards. Nowadays in the age of sub-miniature surface mount components, metric units are commonly used. This results that the PCB (Printed Circuit Board) makes use of both, usually the grid where the components are places is imperial, the outside dimension and SMD (Surface Mount Devices) are metrical. In PCB design the unit mil is quite common: 1mil = 1/1000 inch = 25.4 um
Kicad
http://kicad-pcb.org/ is a GPL application without licenses limitations. Thanks to CERN’s key philosophies its popularity increased: https://cernandsocietyfounda- tion.cern/projects/kicad-development
The pdf English documentation including a tutorial (the handbooks) are in a directory as:/usr/
share/doc/kicad-doc-5.1.0/help/en
https://en.wikibooks.org/wiki/Kicad/Kicad http://www.kicadlib.org/for additional libraries When a new project is created, the ASCII readable file with the extension *.pro is created containing the project information. In general all files Kicad is using are ASCII files and can be read and edited.