Difference: ImplementingTheArduinoToolbox (6 vs. 7)

Revision 72019-02-07 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Scilab"

Implementing the Arduino toolbox

The program structure

Line: 39 to 39
 The Arduino has several 10 bit ADCs on chip which can be used to read analog voltage levels. Here is the command code:

Ap: reads the voltage level from analog pin p

Added:
>
>

Interrupts

Normally interrupts can only be generated on pins 2 and 3 on an Arduino Uno or Nano. However, there are also so-called "PinChangeInterrupts" which allow to hook up an interrupt service routine when a signal level change on a GPIO pin happens. This can be "FALLING" or "RISING" for a falling or rising edge of the signal or it can be "CHANGE" for both edges.

Unfortunately there is a problem when using this with the SoftSerial library because both libraries use the same interrupt vectors. Since for our debugging port we only have to send but to not receive message I use the SendonlySoftSerial library attached to this page:

https://iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/SendOnlySoftwareSerial.zip

These are the protocol codes sent to the Arduino:

Iacup: a: attach pin p for c: change mode f: falling edge: r: rising edge, u: updown: u: up-counter, d: down-counter c: clear
Idp: d: detach from interrupt on pin p
Irp: r: read no of counts from interrupt counter

Encoder

The rotary encoder also make use of interrupts. It uses 2 signals: clock and data to see when it is turned and in which direction it has been turned. The clock signal is connected to an interrupt and the interrupt service routine, by looking at the data signal, finds out if the encoder was turned clock-wise (a counter increments) of counter-clock-wise (a counter decrements).

xcosEncoder.png encoderResult.png
The above screen dumps show an xcos diagram setting up the encoder, reading it and displaying its value in a plot.
 

The multi-function board

In order to test digital read/write, analog read/write etc. we need an Arduino to which the corresponding hardware is connected, e.g. a switch to be read with digital read, a potentiometer for analog read or an LED for digital write... An easy solution is to use the multi-function board which has all these connections already done and which must simply be installed as a piggy back board onto e.g. an Arduino Uno.

Line: 56 to 72
  https://iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/multiFunctionBoard.pdf
Changed:
<
<
I use GPIO pin 2 as TX line for a SoftSerial port onto which I send debugging messages. There is a problem when using this with the PinChangeInterrupt library because both libraries use the same interrupt vectors. Since for our debugging port we only have to send but to not receive message I use the SendonlySoftSerial library attached to this page:

https://iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/SendOnlySoftwareSerial.zip

>
>
I use GPIO pin 2 as TX line for a SoftSerial port onto which I send debugging messages.
 

The Arduino server program and the test procedure

With this information it is possible to develop the first version of the Arduino server. Since all it needs is input from the serial line we can write a simple C program to test the server. A program asking for the server version (and printing it) as well as the Arduino server are attached to this TWiki page.

Line: 84 to 98
  A tar archive with a Xcos toolbox containing Digital Write as well as as a basic stepper motor xcos block is attached to this page:
Changed:
<
<
https://iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/arduino-linux_1.5-src-v0.4.tar.gz
>
>
https://iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/arduino-linux_1.6-src-6feb.tar.gz
  This is the original arduino_1.5-src archive downloaded from git which I modified to run on Linux. Only Digital Write and the stepper motor module are working. The other modules are still part of the archive but will most probably not work. In the original archive the stepper motor block was removed from the Arduino palettes. It has been put back. The original Arduino sketches have been moved into arduino.old and a new server sketch developed which you find in the arduino folder.
Line: 132 to 146
 
META FILEATTACHMENT attachment="palette.png" attr="" comment="" date="1547645846" name="palette.png" path="palette.png" size="30131" user="UliRaich" version="1"
META FILEATTACHMENT attachment="loader.png" attr="" comment="" date="1547645846" name="loader.png" path="loader.png" size="11433" user="UliRaich" version="1"
META FILEATTACHMENT attachment="builder.png" attr="" comment="" date="1547645848" name="builder.png" path="builder.png" size="159072" user="UliRaich" version="1"
Deleted:
<
<
META FILEATTACHMENT attachment="arduino-linux_1.5-src-v0.4.tar.gz" attr="" comment="" date="1547831976" name="arduino-linux_1.5-src-v0.4.tar.gz" path="arduino-linux_1.5-src-v0.4.tar.gz" size="1844077" user="UliRaich" version="1"
 
META FILEATTACHMENT attachment="multi-function.png" attr="" comment="" date="1549099775" name="multi-function.png" path="multi-function.png" size="218191" user="UliRaich" version="1"
META FILEATTACHMENT attachment="multiFunctionBoard.pdf" attr="" comment="" date="1549100057" name="multiFunctionBoard.pdf" path="multiFunctionBoard.pdf" size="23827" user="UliRaich" version="1"
META FILEATTACHMENT attachment="SendOnlySoftwareSerial.zip" attr="" comment="" date="1549100822" name="SendOnlySoftwareSerial.zip" path="SendOnlySoftwareSerial.zip" size="4452" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="xcosEncoder.png" attr="" comment="" date="1549551382" name="xcosEncoder.png" path="xcosEncoder.png" size="32649" user="UliRaich" version="1"
META FILEATTACHMENT attachment="encoderResult.png" attr="" comment="" date="1549551382" name="encoderResult.png" path="encoderResult.png" size="15252" user="UliRaich" version="1"
META FILEATTACHMENT attachment="arduino-linux_1.6-src-6feb.tar.gz" attr="" comment="" date="1549551606" name="arduino-linux_1.6-src-6feb.tar.gz" path="arduino-linux_1.6-src-6feb.tar.gz" size="2722718" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback