Difference between revisions of "SmartTerminal for Controlino"
Russ hensel (talk | contribs) |
Russ hensel (talk | contribs) |
||
Line 36: | Line 36: | ||
note that this is just setting self.send_ctrls to a list of strings. | note that this is just setting self.send_ctrls to a list of strings. | ||
− | Run the | + | Run the SmartTerminal again, this time you will find the above commands loaded into the first several send areas as defaults. Try them out, all but "Controlino" respond with done. Invalid commands also seem to get no response. These commands look like they are supposed to have numbers appended as well, it would be nice if we had some values in place just to let you know what the expected form is. |
= Try Blink = | = Try Blink = |
Revision as of 14:54, 29 January 2017
What
This is part of the Instrumentino/Smart Terminal Challenge. In this part I am going to try to adapt the SmartTerminal ( PC/Python ) Python Smart Terminal to the ( microcontroller ) Controlino program Controlino Notes.
First Connection
Here we will just try to establish a basic connection between the two programs, typically this involves matching the communications parameters. Baud rate is, perhaps, the most basic.
Steps:
- go to Controlino program find baudrate #define SERIAL0_BAUD 115200
- go to SmartTerminal parameters.py and define a new mode Controlino:
- self.mode = "Controlino" # this is not really needed but this way it is easy to turn on and off the Controlino settings.
- find self.baudrate and add at end of baud rate section
if self.mode == "Controlino": self.baudrate = 19200
this way of setting the baud rate will only be in effect for the mode Controlino which, for now, we will implement as a straight terminal
Install Controlino on your arduino and fire up both the SmartTerminal and the arduino. Open the port and send "set" the arduino responds with "done", the eagle has landed.
Add strings for commands to interface
- look at the bottom of the C program and extract the following commands: "Set", "Controlino", "BlinkPin", "Read", "Write", "SetPwmFreq"
- find the section in Parameters ( in parameters.py ) that looks something like:
elif self.mode == "MotorDriver": self.send_ctrls = [ ...
and add a clause to the if then section like:
elif self.mode == "Controlino": self.send_ctrls = [ "Set", "Controlino", "BlinkPin", "Read", "Write", "SetPwmFreq" ]
note that this is just setting self.send_ctrls to a list of strings.
Run the SmartTerminal again, this time you will find the above commands loaded into the first several send areas as defaults. Try them out, all but "Controlino" respond with done. Invalid commands also seem to get no response. These commands look like they are supposed to have numbers appended as well, it would be nice if we had some values in place just to let you know what the expected form is.
Try Blink
- Blink using BlinkPin looks like it might be easy to use and test so lets look at it.
- the command seems to link to cmdBlinkPin(argV) and searching on it we find
void cmdBlinkPin(char **argV) { blinkingPin = strtol(argV[1], NULL, 10); blinkingDelayMs = strtol(argV[2], NULL, 10); pinMode(blinkingPin, OUTPUT); blinkLastChangeMs = millis(); startBlinking = true;
This in turns suggests the command "BlinkPin 5 300" will blink pin 5 with a delay ( half period or full period ) of 300 ms. Looking at my board it is very easy to put in a led on pin 7 so lets try "BlinkPin 7 300" as a command.
Back to
elif self.mode == "Controlino": self.send_ctrls = [ "Set", "Controlino", "BlinkPin", "Read", "Write", "SetPwmFreq" ]
lets change it to
elif self.mode == "Controlino": self.send_ctrls = [ "Set", "Controlino", "BlinkPin 7 300", "Read", "Write", "SetPwmFreq" ]