here is the next rewrite for anyone interested, don't worry about the massive errors in the code
its just to show where i am trying to head (if you are a code head..which i am not..who would have guessed hey
I am SUPER aware that this will run the initialization sequence on power up and immediately start outputting to serial (well i hope it will)
I am going to hook the Arduino up the Logic4 for testing... not the power chair itself,
i want to see the wave forms match or how far they vary from each other and tweak it.
- Code: Select all
#define INHPIN 11 // well its not used for testing this code as yet but will need inhibit at some point
#define JSIGPIN 1 // TX pin
#define LEDPIN 13 // Other output pin to connect to Jazzy line that pulses 255 all the time ?
#define pwrBtn 7 // On/Off button Digital Pin 4, has internal pull up resistor ? or was that pull down ?
unsigned char data[10];
unsigned long timer = 0;
int Ypin = A0;
int Xpin = A1;
int YpinValue;
int XpinValue;
int startYvalue = 192;
int startXvalue = 192;
void setup() {
// Dynamic Shark initialization sequence
// Bytes starting with (0x60) are Joystick in put data
// Bytes starting with (0x74) are initialization packets
// (0x0F) is the end packet notification, delays mostly 10ms till Joy has ( booted up ? 3.3seconds)
// then settles to a delay of 17.16ms
Serial.begin(38400, SERIAL_8E1);
digitalWrite (JSIGPIN, HIGH); // Power button pressed On (from off state)
delay(293);
digitalWrite (JSIGPIN, LOW);
delay(10);
// Fist packet of data sent from Joystick
Serial.write((0x74), (0x82), (0x85), (0x82), (0x80), (0x88), (0xCD), (0xA0), (0x80), (0x8D), (0x0F));
delay(1);
Serial.write((0x05), (0x80), (0xFA));
delay(1);
Serial.write(0x0F);
// delay till next group of data
delay(1);
// Second group of data
// Appears to be Joystick raw data reads/reads after interpretation by Wizard Software settings
Serial.write((0x60), (0xC0), (0xBF), (0xFF), (0xCD), (0x80), (0x8C), (0x80), (0xC8), (0x0F));
delay(2);
// Third group of data
// Inhibit files ? till joystick has booted up fully ?
// All inhibit bytes start with (0x61) and stop after 3.3seconds
Serial.write((0x61), (0x80), (0x80), (0xC0), (0x80), (0x80), (0x80), (0x80), (0xDE));
delay(0)
// End bits are (0x0F)
Serial.write(0x0F)
// now a cycle of Joystick (0x060), inhibit/raw/controller values (0x61) continues till 3.3seconds
// Then a steady stream of Joystick data with 17.16ms delay between bytes of data.
// Start bit, 8 data bits, End Bit
// Start bit " ' "(0x60) Address ?
// Bit 1 "192"(0xC0) Y axis data
// Bit 2 "192"(0xC0) X axis data
// Bit 3 "255"(0xFF) Speed max setting
// Bit 4 "192"(0xC0) Speed fine tune ?
// Bit 5 "128"(0x80) Horn off/ 130on
// Bit 6 "140"(0x8C) Joystick on ?
// Bit 7 "128"(0x80) Chair mode (128drive/129tilt)
// Bit 8 "212"(0xD4) Some other XY modifier ?
// End Bit "15"(0x0F) End packet
// is 3.2 seconds of data packets necessary ?
// would not a "if bit 1 <>='192'(0xC0)" then inhibit enable ? suffice
}
pinMode(pwrBtn, INPUT_PULLUP);
pinMode(LEDPIN, OUTPUT);
pinMode(INHPIN, OUTPUT);
void loop() {
//read the value from the Y axis on port A0
YpinValue = analogRead(Ypin);
//read the value from the X axis on Port A1
XpinValue = analogRead(Xpin);
///build serial packet
data[0]= (0x60); // Joystick packets start with this " ' " not accepted had to use hex
data[1]= YpinValue; // Joystick Y value
data[2]= XpinValue; // Joystick X value
data[3]= 255; // Max speed setting via turtle/hare buttons on joystick
data[4]= 192; // Speed Fine Tune ?
data[5]= 128; // default horn off, horn on value is 130
data[6]= 140; // joystick On Value ?
data[7]= 128; // chair mode/ drive 128, tilt/aux output 129
data[8]= 212; // some other XY modifier..maybe acceleration/de settings
data[9]= 15; // all packets end with this identifier
data[10]=0xff-(data[0]+data[1]+data[2]+data[3]+data[4]); //-Check sum
for(unsigned char i=0;i<11;i++);
Serial.write(data[i]);
//
}









