RCP stimulator: Difference between revisions

Line 5: Line 5:


===Input Mode===
===Input Mode===
Configure your GPIOs under Setup/GPIO for input mode, and then configure a gauge on the dash to observe the state.  
Configure your GPIOs under Setup/Digital In/Out for input mode, and then configure a gauge on the dash to observe the state.  


When the Button is pressed, the value will read as '1', indicating the GPIO is connected to ground (Active Low).
When the Button is pressed, the value will read as '1', indicating the GPIO is connected to ground (Active Low).
Line 12: Line 12:
Run this script to demonstrate the GPIOs in output mode.
Run this script to demonstrate the GPIOs in output mode.
   
   
* '''Note''' Ensure the GPIO ports are in output mode under RaceCapture Setup / GPIO.  
* '''Note''' Ensure the GPIO ports are in output mode under RaceCapture Setup / Digital In/Out.  


<pre>
<pre>

Revision as of 04:46, 6 January 2019

GPIO

The respective LEDs will illuminate when the GPIO port is active Low (connected to ground) - either by pressing the switch, or if activated by RaceCapture when the GPIO is in output mode.

Input Mode

Configure your GPIOs under Setup/Digital In/Out for input mode, and then configure a gauge on the dash to observe the state.

When the Button is pressed, the value will read as '1', indicating the GPIO is connected to ground (Active Low).

Output mode and Demo script

Run this script to demonstrate the GPIOs in output mode.

  • Note Ensure the GPIO ports are in output mode under RaceCapture Setup / Digital In/Out.
--Demo script for toggling LEDs on stimulator board
--GPIOs must be set for output mode in RaceCapture Setup

setTickRate(1)

count = 0

function onTick()
  --toggle LEDs
  local state = count % 2
  setGpio(0, state == 0)
  setGpio(1, state == 0)
  setGpio(2, state == 0)
  count = count + 1

end

RS232 serial output

The stimulator will output the current Analog channel data on the serial port, which can be read by the Aux Serial input of RaceCapture/Pro.

Baud Rate

Baud rate is 115200, 8N1

Format

The output format is CSV with the following columns:

  • Timestamp in milliseconds
  • Channel 1 value (0-10000)
  • Channel 2 value (0-10000)
  • Channel 3 value (0-10000)
  • Channel 4 value (0-10000)
  • Value echoed back from received data

Example Lua script to read serial data

--initialize Aux serial port to 115200, 8, N, 1
initSer(6, 115200, 8, 0, 1)

setTickRate(10)

function onTick()
  --write something to be echoed back
  writeSer(6, 'echo')
  --read a line from the aux serial port with a 100ms timeout
  value = readSer(6, 1000)
  if value ~= nil and value ~= '' then
    print('read value: ' ..value)
  end
end

Stimulator serial data script.png

Example Raw output stream from Stimulator

352023 ,0,0,0,0,echo
352223 ,0,0,0,0,echo
352423 ,0,0,0,0,echo
352623 ,0,0,0,0,echo
352823 ,0,0,0,0,echo
353023 ,0,0,0,0,echo
353223 ,275,0,0,0,echo
353423 ,1680,0,0,0,echo
353623 ,1680,0,0,0,echo
353823 ,1680,0,0,0,echo
354023 ,1672,0,0,0,echo
354223 ,1697,1181,0,0,echo
354423 ,1699,2666,0,0,echo
354623 ,1704,2649,0,0,echo
354823 ,1706,2656,0,0,echo
355023 ,1692,2647,0,0,echo
355223 ,1728,4554,0,0,echo
355423 ,1724,4595,0,0,echo
355623 ,1741,4588,0,0,echo
355823 ,1753,4590,1199,0,echo
356023 ,1750,4588,1323,0,echo
356223 ,1755,4588,4730,0,echo
356423 ,1750,4588,4984,0,echo
356623 ,1758,4586,4981,0,echo
356823 ,1750,4583,4959,1299,echo
357023 ,1758,4586,4964,4129,echo
357223 ,1758,4588,4947,4473,echo
357423 ,1753,4586,4957,5269,echo
357623 ,1753,4586,4957,5768,echo