Difference: ImplementingTheArduinoToolbox (3 vs. 4)

Revision 42019-01-16 - UliRaich

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

Implementing the Arduino toolbox

The program structure

Line: 32 to 32
 Sanp: Where "S" identifies for the stepper motor device, "a" stands for "attach" n is the GPIO pin and p is the pulse (N1 .. N4 or the stepping motor driver module) . The command also programs the GPIO pins as output. Sa21 will therefore attach GPIO pin 2 to the first stepping motor driver input (N1 on the driver card).

Sm: moves the stepping motor by 1 step

Added:
>
>
Sc: Clears all coil signals to low
 

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: 53 to 55
 stepper.png

And in fact you see the motor turn when it receives the Sm commands.

Added:
>
>

How to bring the demo system up

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:

https://afnog.iotworkshop.africa/pub/Embedded_Systems/ImplementingTheArduinoToolbox/arduino-linux_1.5-src.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.

To install everything please

  • create a folder /opt/ucc/scilab
  • unpack the above tar archive into this folder.
Have a look in the arduino folder where you should find the server sketch called toolbox_arduino_v0.2.ino. This sketch must be uploaded onto an Arduino. I used an Arduino Nano but an Uno or Mega should work as well. For debugging I use a Softserial port. Connect your PC via a USB to serial converter to the Arduino. GPIO pin 10 on the Arduino corresponds to the Arduino Tx line (Rx of the USB to serial adapter) and pin 11 corresponds to Arduino Rx (see also the definitions in the sketch).

In arduino/serverTest you will find test programs for the server sketch as well as interface functions in serialLib which interface the XCos block Scilab code to the serial driver. The test program,running on the PC, (have a look at blink2.c) passes through these functions and calls the driver in exactly the same way that Scilab will use. For the moment only 2 such test programs are available:

  • blink2.c reading out the server version and blinking the Arduino builtin LED on GPIO pin 13
  • stepper.c which make the stepper motor move. The coil pins on the stepping motor controller (N1 .. N4) must be connected to Arduino GPIO pins 2..5
Try to make the Arduino server sketch work with these programs first.

Then start Scilab. Load the macros

  • builder.sce
  • loader.sce
  • unloader.sce
Execute the builder.sce script.

You should see something similar to this:

builder.png

If the builder exits successfully then you can start the loader adding the Arduino features into the Scilab system. This is what you should see:

loader.png

Now you can start xcos either by typing xcos in the command window orr by clicking the Xcos icon (the one looking a bit like an oscilloscope). In the palettes box coming up you should see an Arduino entry:

palette.png

Now you can create a diagram using your new Arduino blocks and run it. The LED should blink or the stepper motor move.

  -- Uli Raich - 2019-01-07
Line: 65 to 104
 
META FILEATTACHMENT attachment="serialLib.png" attr="" comment="" date="1547562536" name="serialLib.png" path="serialLib.png" size="23041" user="UliRaich" version="1"
META FILEATTACHMENT attachment="stepper.png" attr="" comment="" date="1547562537" name="stepper.png" path="stepper.png" size="15446" user="UliRaich" version="1"
META FILEATTACHMENT attachment="blink2.png" attr="" comment="" date="1547563216" name="blink2.png" path="blink2.png" size="63326" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="arduino-linux_1.5-src.tar.gz" attr="" comment="" date="1547645323" name="arduino-linux_1.5-src.tar.gz" path="arduino-linux_1.5-src.tar.gz" size="1841722" user="UliRaich" version="1"
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"
 
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