A: Data logging can be very useful in order to capture rare events during the normal system operation. Massive amounts of data can be captured using an inexpensive data logging module. This module along with the included SD Card can capture just about anything, virtually forever.
This module can very easily be attached to any of the roboteq's motor controller serial port. Then, using microbasic scripting, any operating data can be fetched from the controller and send to the logger. Wiring between the controller takes only 3 wires and a resistor as shown in the diagram below.
This circuit will work with recent versions of Roboteq motor controllers that can have the R232 port inverted. See this FAQ for a full description of this simplified RS232 to TTL serial interface scheme.
Older models require a RS232 to TTL adapter, like this one that we offer, to be inserted between the controller's TxData and the logger RXI.
As soon as powered on, the data logger will capture every character it sees on its RXI input onto the SDCard. By default, the logger's serial port is set to 9600 bits/s. The controller's serial port must therefore be configured to 9600 instead of its 115200. For full bandwidth capture, best is to change the logger serial port setting instead to 115200.
To do this follow these steps
- power up the logger at least once. This will create a defaut configuration file if the SDCard is empty
- disconnect the logger
- take the SDCard out and into a PC
- edit the config.txt file
- change 9600 to 115200
- save the changed file
- put the SDCard back in the logger
Then on the controller side load a script that will capture all the operating parameters of interest and output them periodically to the controller's serial port. Use the script below and adapt it to fit your needs.
dim delay as integer
dim BatAmps as integer
dim MotAmps as integer
dim Volts as integer
dim PWM as integer
dim TimeStamp as integer
dim Counts as integer
dim Capture as boolean
dim HiSpeedCapture as boolean
setconfig(_SCRO, 1) ' Force the print output to the serial port
' Capture all the paramters to be logged
BatAmps = getvalue(_BA, 1)
MotAmps = getvalue(_A, 1)
Volts = getvalue(_V, 2)
PWM = getvalue(_P, 1)
' Detect condition during which we want to capture log
' for example while any power is applied to the motor
if PWM <> 0 then Capture = true else Capture = false
' Detect condition during which we want to capture log at a higher rate
' for example while voltage drops because of high load
if Volts < 100 then HiSpeedCapture = true else HiSpeedCapture = false
if Capture = true ' check if capture is on
if HiSpeedCapture or Counts = 10 ' capture at every loop in hi speed mode. Else every 10 loops
print(TimeStamp,"\t",BatAmps, "\t",MotAmps, "\t",Volts, "\t",PWM,"\r\n")
Counts = 0
wait(10) ' 10ms for 100Hz high speed capture, 10Hz regular capture
After testing the script manually, set the controller configuration to Script Autostart. The controller will then send data every time it is turned on.
To read the log, disconnect the logger or turn off the controller, remove the card and insert it in the PC. Open the log file with excel. Because tabs were inserted between each value, they will fit nicely into separate columns.
Once in excel, the data can easily be plotted and analysed