Pages

Thursday 11 January 2024

Comduino Terminal v 2.0

 This application is a test utility for reading and displaying states of digital and analog inputs, and setting states of outputs. Read post of Tuesday18th June, 2013 for a full explanation. 

This is a ClickOnce distribution so there is no fancy installer. Eventually I may get around to using a proper installation utility which will result in a single .exe or .msi setup file. For the moment I have uploaded the installation files to Google Drive as a zip archive. Download the zip file to your desktop and unzip it. This creates a folder called ComduinoTerminal on your desktop  (or a sub folder in the folder where you extracted the zip file). Run setup.exe in this folder to install the application. There is probably a better way of doing this.... any suggestions would be welcome.
This new version has a panel on the form with a series of buttons, one for each output allowing the state of outputs to be set.

 Download here:  Comduino Terminal v2.0

This application is specifically for the Leonardo board. If you want to use it with other boards, you need to modify the code, which basically involves changing #defines for number of channels in the sketch and the equivalent in the VB code. I have used the aliases which refer to pins e.g. A0, A1 etc as described in ..Program Files\Arduino\hardware\arduino\avr\variants so these may need to be extended.

The accompanying sketch for a Leonardo board is here: Comduino1_0.ino 










Comduino Terminal v 1.0

This Arduino test utility should have been called Leonardo Terminal v 2.0,  but I renamed it because it can  be used with all "flavours" of Arduino board, not specifically the Leonardo. The code is reasonably well documented so it shouldn't take much effort to change the relevant #defines and pin names to make it work with which ever version of Arduino board you are using.

These are the changes since Leonardo v1.0 (Read post of Tuesday18th June, 2013 first)

  • On the fly checking of connection/disconnection of USB cable. When a cable is connected, the new port is automatically added to the list of ports
  • A string of data can now be sent in single shot or repetitive mode
  • Added a facility for scanning all inputs and reporting their values/states. Each pin can be enabled/disabled and set as an analog or digital input. This can also be done globally for all pins by checking the boxes at the top of the table
  • Cleaned up the code for logging to an Excel file. All channels can now be logged

You can download the code here:

Comduino Terminal v1.0 for Windows 

It consists of 4 files. Just create a new project and save the 4 files in your project folder. Next add Form1.vb and the class module Pin.vb to your new project.

The accompanying Comduino sketch has support for extra Arduino language commands. See the start of the sketch for details. The 18 June 2013 post provides more info also about this project.

Comduino v1.0 can be downloaded here:

Comduino for Arduino 

Edit the sketch to suit your Arduino board:

I put together a quick YouTube video demo of  the application here (sorry no commentary yet)

Comduino video

 

If you found this free software useful, please take the time to visit my articles on HubPages here: http://eugbug.hubpages.com Pins, or tweets of articles would be much appreciated!


Getting the Maxim DS18B20 temperature to work

 I have finally got this device working properly. I used Tom Boyd's tutorial here http://sheepdogguides.com/arduino/ar3ne1tt.htm and adjusted his code slightly. Since my sensor was powered from the 5v line rather than using parasitic power, I was able to  issue read slots and wait for a 1, indicating end of conversion. Initially I was getting errors approximately every few hundred readings. The data sheet indicates a 60us minimum period for read slots and 480 us for write slots. Increasing the 60us to 80us reduced the frequency of these errors. However I have now decided to use the Onewire library which includes CRC checking on incoming data.

Arduino Command Interpreter

 

My First Arduino Project! 

This is my first Arduino project which I started over a month ago. My intention was to get a basic system up and running and establish rudimentary comms with a PC. I have a background in programming Zilog Z8 microcontrollers for data loggers, so getting the hang of the Atmel processor was a case of brushing off the dust on my knowledge of  these devices. Luckily libraries are available for programming the Arduino board so I didn't have to do any low level stuff as was the case with the Z8.
The project is broadly divided into two parts; the sketch which runs on  Arduino, and the application running on the PC (Leonardo Terminal). The sketch implements a simple command interpreter for the Arduino board, specifically the Leonardo and the PC application is a terminal program which allows users to enter commands which are passed over the USB virtual serial port to the Arduino board.  These commands instruct the microcontroller to set the states of digital outputs, generate and vary the duty cycle of a PWM signal, and read the state or value of digital and analog inputs.

The Sketch 

Incoming data on the USB serial port is echoed back to the remote terminal and also to a 16 x 2 LCD display if used. Each character is appended to a  command buffer. When a CR code  is received,the contents of the command buffer are parsed to extract the command and its parameters. The command is then executed. Commands are translated to the Arduino digitalRead, digitalWrite, analogRead, analogWrite, Tone and noTone functions. The sketch can be used with the Leonardoterminal VB application or any terminal program.  The syntax of commands understood by the interpreter is as follows:

DIN pin or DIN pin PU 
Read the state on a digital pin,  the optional parameter PU instructs the board  that pull up resistors should be used.  Value printed on LCD or output to serial port is 0 LOW, 1 HIGH
 
DOUT pin state 
Output to a digital pin. state is 1=HIGH, 0=LOW

AIN pin 

Read the value on the specified analog pin. Display to LCD and output to serial port

AOUT pin value

Implements PWM on the specified pin, value ranges 0-255. The frequency of the PWM  signal is 490 hertz approx

TONE pin pitch duration  

pitch is in hertz, duration is milliseconds          

NOTONE    pin

Turns off the tone on the specified pin                 


Leonardo Terminal 

The application which runs on a PC was written in Visual Basic 2008. This application is a simple terminal program which can be used for communicating with an Arduino board, or any other serial device.  Data is entered into a textbox and an adjacent textbox displays data received.  Two text boxes allow strings of data to be sent when "send" buttons are pressed.  The following functions on the form are specific to an Arduino board:

Monitor Analog Input 

Displays the value read from the specified pin. The pin is scanned every second

Monitor Digital Input 

Displays "HIGH" or "LOW" depending on the state of the specified pin. Results are updated every second

PWM output   

Enables PWM on the specified pin and the duty cycle for the PWM signal is set by the position of the wiper on the tracker bar

Commands entered into the Data Sent text box are translated to the Arduino digitalRead, digitalWrite, analogRead,  analogWrite, Tone and noTone functions.
Data can be written to an Excel file, however you must have Excel installed for this to work. I have only implemented logging of data on the chosen analog channel. Files can be appended or overwritten.
The software detects when a USB cable cable is plugged in and updates a list of available ports. When the cable is unplugged, the list is re-populated. 



Improvements 

There is a lot of room for improvement in the code. Rather than using a text based protocol for requesting and setting the states of pins, data could be sent and received in packets in binary format. Instead of using digitalRead, analogRead and other Arduino functions for getting/setting the states of pins, registers could be read directly and results sent as a block of data.
The advantage of a text based protocol however is that any terminal program can be used for checking/setting pins without the requirement to encode/decode data.
No error checking is implemented. Checksums could be added to sent and received commands/responses for basic validity checking of data.
The Leonardo Terminal application only receives and sets one pin at a time. Future versions will allow the full range of inputs/outputs on the board to be controlled. So for example the user can choose whether a pin is input or output, PWM output and if it should be logged.



Parts Required

Leonardo board from Dealextreme.com or other supplier.
DX.com don't appear to stock an official "Made in Italy" Arduino Leonardo anymore. However you can buy an "Eduino" clone version for $14.60 here:

http://dx.com/p/diy-eduino-leonardo-module-blue-black-213956?Utm_rid=55371787&Utm_source=affiliate
 
2 x 16 LCD display also from DealExtreme

The one I bought had a blue display with white characters. You can buy it here:

http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356?Utm_rid=55371787&Utm_source=affiliate

However the backlight must be illuminated to read the characters. An alternative is this one with black characters on a yellow/green background:

http://dx.com/p/1602a-16-x-2-lines-black-character-lcd-module-w-chartreuse-yellow-backlight-dc-5v-151977?Utm_rid=55371787&Utm_source=affiliate 

You also need a strip of pin headers if you want to plug the LCD into a breadboard.

Breadboards can be bought from DX.com here:

http://dx.com/p/830-point-solderless-breadboard-118354?Utm_rid=55371787&Utm_source=affiliate

Breadboard Connections

The breadboard setup was drafted using Fritzing which can be downloaded here: http://fritzing.org/
I used an Uno board instead of a Leonardo, however the pin connections are the same.
5 volts and ground from the Leonardo feed the two top rails of the breadboard. Only 4 data lines of the LCD need to be connected to the Arduino. A 10k pot is used to adjust the contrast on the LCD display. 
Johan van Tongeren has some information and close-up photos of connecting this type of LCD here: 
http://www.dreamdealer.nl/tutorials/connecting_a_1602a_lcd_display_and_a_light_sensor_to_arduino_uno.html



This is the schematic:


You can download the sketch here:

Leonardo.ino v1.0

 

This is a screen dump of the Leonardo Terminal program




........and you can download the Leonardo Terminal VB code here. Unzip the folder into your Visual Studio projects folder.

Leonardo Terminal v1.0

Don't forget to visit my HubPages articles, http://eugbug.hubpages.com  (some likes or tweets would be appreciated!)