
{
//build serial packet
data[0] = (0x74); // start identifier. " t "
data[1] = (130); // Joystick speed
data[2] = (133); // Joystick direction
data[3] = (130); // Max speed setting via turtle/hare buttons on joystick?
data[4] = (128); // Speed Fine Tune ?
data[5] = (136); // default horn off, horn on value is 130
data[6] = (205); //data[6] = 205; // joystick On Value ?
data[7] = (160); //data[7] = 160; // chair mode/ drive 128, tilt/aux output 129
data[8] = (128); //data[8] = 128; //not used?
data[9] = 0xff - (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]); //-Checksum expected result data[9] = (141);
data[10] = (15); //data[10] = 15; // all packets end with this identifier
for (unsigned char i = 0; i < 11; i++)
sharkSerial.write(data[i]);
}int DataSum = 0;
for (byte i = 0, i<=8, i++){
DataSum = DataSum + Data[i];
}
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. Blocks of data entering these systems get a short check value attached, based on the remainder of a polynomial division of their contents. On retrieval, the calculation is repeated and, in the event the check values do not match, corrective action can be taken against data corruption.
CRCs are so called because the check (data verification) value is a redundancy (it expands the message without adding information) and the algorithm is based on cyclic codes. CRCs are popular because they are simple to implement in binary hardware, easy to analyze mathematically, and particularly good at detecting common errors caused by noise in transmission channels. Because the check value has a fixed length, the function that generates it is occasionally used as a hash function.
Data shall be sent in packet on the Shark Bus. Packets shall consist of a start byte, which includes the type of the packet and its length, followed by the data, followed by a check sum, The exception to this is the "Transmit Finished" packet , which shall be a single, fixed value byte.
gcebiker wrote:Short excerpt
As soon as i moved the joystick , the check sum was changing and thus the Shark Power Base stopped responding to invalid data.
Finally all packets except for the Transmit Finished packet shall include a one-byte checksum, which is defined as 0x7F - ( least-significant 7 bits of ( sum of all data bytes and start byte ) ).
The first, or start, byte of a packet defines its type and the length of the data that it contains. The type is in bits 3-0, and the length is in bits 6-4. This allows for 16 packet types, each containing up to 8 bytes of data (the length field does not include the start byte nor the checksum). Note that the number in the length field is one less than the data length: 000 = 1 data byte, 111 = 8 data bytes. The "Transmit Finished" byte is an exception to this, as it has a length field of 000 but has zero data bytes and no checksum.
Serial.print ("0b");
Serial.print (variable, BIN);data[8] = (0x7F) - (Lsb7 - (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7]));data[8] = (0x7F) - (0b01111111 & (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7])) ;data[9] = (0x7F) - (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]); data[8] = (0x7F) - ((0b01111111) & (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7])) ; byte sum = 0;
for(int i=0; i < 9; i++)
sum+=data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[9] = 0x7f - sum;
int len = (int)(data[0] >>4) & 0x07); //assumes start byte is data[0]
byte sum = 0;
for(int i=0; i < len; i++)
sum+=data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[9] = 0x7f - sum;
byte data[10];
void setup() {
Serial.begin(115200);
Serial.println(__FILE__ " - " __DATE__ " " __TIME__);
Serial.println();
data[0] = (0x74); // start identifier. " t "
data[1] = (130); // Joystick speed
data[2] = (133); // Joystick direction
data[3] = (130); // Max speed setting via turtle/hare buttons on joystick?
data[4] = (128); // Speed Fine Tune ?
data[5] = (136); // default horn off, horn on value is 130
data[6] = (205); //data[6] = 205; // joystick On Value ?
data[7] = (160); //data[7] = 160; // chair mode/ drive 128, tilt/aux output 129
data[8] = (128); //data[8] = 128; //not used?
CheckSum ();
}
void loop() {
}
void CheckSum (){
byte ByteSum = (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]);
int IntSum = (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]);
Serial.print ("ByteSum = 0b");
Serial.print (ByteSum, BIN);
Serial.print (" = 0x");
Serial.print (ByteSum, HEX);
Serial.print (" = 0d");
Serial.println (ByteSum);
data[9] = 0x7F - ByteSum;
Serial.print ("'byte' CheckSum = 0x7F - ByteSum = 0b");
Serial.print (data[9], BIN);
Serial.print (" = 0x");
Serial.print (data[9], HEX);
Serial.print (" = 0d");
Serial.println (data[9]);
Serial.println ();
ByteSum = 0b01111111 & ByteSum,
Serial.print ("7lsb ByteSum = 0b");
Serial.print (ByteSum, BIN);
Serial.print (" = 0x");
Serial.print (ByteSum, HEX);
Serial.print (" = 0d");
Serial.println (ByteSum);
data[9] = 0x7F - ByteSum;
Serial.print ("'7lsb byte' CheckSum = 0x7F - 7lsb ByteSum =0b");
Serial.print (data[9], BIN);
Serial.print (" = 0x");
Serial.print (data[9], HEX);
Serial.print (" = 0d");
Serial.println (data[9]);
Serial.println ();
Serial.println ("***********************************");
Serial.println ();
Serial.print ("IntSum = 0b");
Serial.print (IntSum, BIN);
Serial.print (" = 0x");
Serial.print (IntSum, HEX);
Serial.print (" = 0d");
Serial.println (IntSum);
data[9] = 0x7F - IntSum;
Serial.print ("'byte' CheckSum = 0x7F - IntSum = 0b");
Serial.print (data[9], BIN);
Serial.print (" = 0x");
Serial.print (data[9], HEX);
Serial.print (" = 0d");
Serial.println (data[9]);
Serial.println ();
IntSum = 0b01111111 & IntSum,
Serial.print ("7lsb IntSum = 0b");
Serial.print (IntSum, BIN);
Serial.print (" = 0x");
Serial.print (IntSum, HEX);
Serial.print (" = 0d");
Serial.println (IntSum);
data[9] = 0x7F - IntSum;
Serial.print ("'7lsb int' CheckSum = 0x7F - 7lsb IntSum =0b");
Serial.print (data[9], BIN);
Serial.print (" = 0x");
Serial.print (data[9], HEX);
Serial.print (" = 0d");
Serial.println (data[9]);
Serial.println ();
Serial.println ("***********************************");
Serial.println ();
} //end CheckSum ()ByteSum = 0b11110010 = 0xF2 = 0d242'byte' CheckSum = 0x7F - ByteSum = 0b10001101 = 0x8D = 0d1417lsb ByteSum = 0b1110010 = 0x72 = 0d114
'7lsb byte' CheckSum = 0x7F - 7lsb ByteSum =0b1101 = 0xD = 0d13
IntSum = 0b10011110010 = 0x4F2 = 0d1266
'byte' CheckSum = 0x7F - IntSum = 0b10001101 = 0x8D = 0d141
7lsb IntSum = 0b1110010 = 0x72 = 0d114
'7lsb int' CheckSum = 0x7F - 7lsb IntSum =0b1101 = 0xD = 0d13
data[9] = 0x7F - (data[0]+data[1]+data[2]+data[3]+data[4]+data[5]+data[6]+data[6]+data[8]);
data[9] = data[0]+data[1]+data[2]+data[3]+data[4]+data[5]+data[6]+data[6]+data[8];
data[9] = 0x7F - data[9];LROBBINS wrote:I haven't gone through everything you had in your last post, but did notice a couple things. For one, sometimes you are summing data[0] through data[8] and in other examples you've summed only data[0] through data[7] which will certainly give a different result.
// This sketch is to emulate the packet of data that the Shark Joystick sends
/******************************************************************************
Author: Tony Matthews ammatthews at gmail dot com
License: FreeBSD
******************************************************************************/
/******************************************************************************
Copyright (c) 2015, Tony Matthews
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*******************************************************************************/
// This code is incomplete and still under revision.
// Its also got junk that may not be needed,
// Early testing phases.
// Names for Pins and what they are connected to
// getting ready to use GCDuiNode with the RF24 or Wii Nunchuck (currently hard wired)
// Pin outs for RS485 chip
const int onOffPin = 3; // Digital Pin for software on/off button
const int roPin = 11; // to RO of Max485
const int rePin = 10; // to RE of Max485
const int dePin = 9; // to DE of Max485
const int diPin = 8; // to DI of Max485
const int dataSwitch = 6; // Digital Switch for DG419
const int led = 13 ; // LED state indicator pin
//Boolean name holder for current state.
boolean onOffstate = LOW;
// Analog input pins assignments
const int yPot = A0; // Y Pot input value
const int xPot = A1; // X Pot input value
// Names for analogRead values of Analog Pots
int yPotVal;
int xPotVal;
// Names for Mapped analogRead Values of Pots
unsigned char yPotValMapped;
unsigned char xPotValMapped;
// Size of data packet, tho the packets are not constrained to this size.
// May need to change this value.
unsigned char data[12];
unsigned long timer = 0;
#include <SoftwareSerial.h>
SoftwareSerial sharkSerial (roPin, diPin, false); // 'true' sets this to invert software serial output.
void setup()
{
sharkSerial.begin(38400);
pinMode(led, OUTPUT); // Arduino led to monitor on or off state.
pinMode(onOffPin, INPUT_PULLUP); // Software on/off button, turn on internal pull up resistors.
// Set Data switch pin to Output
digitalWrite(dataSwitch, LOW); //Start Data in LOW = PNP 'on' NPN 'Off'
}
void loop() {
// Starts in Off state from physical power on.
// Check state, if "on" , "turn off" and visa versa.
if (digitalRead(onOffPin) == LOW && onOffstate == HIGH)
{
onOffstate = !onOffstate; //toggles onOffstate from HIGH to LOW (if it was HIGH when the on/off button is pressed)
digitalWrite(dePin, LOW); // hold dePin low when 'off'
digitalWrite(dataSwitch, LOW);
digitalWrite(led, onOffstate); // Turn off the LED on arduino as indication of state
delay (300); //debounce switch delay
}
// check state, if on/off button is pressed, change state to "ON" and run start up sequence.
else if (digitalRead(onOffPin) == LOW && onOffstate == LOW)
{
onOffstate = !onOffstate; // toggle state to HIGH if in'off mode' and on/off button is pressed
digitalWrite(led, onOffstate); // turn on LED pin to get visual indication of on/off state
digitalWrite(dePin, HIGH); // Hold dePin high when transmitting.
sharkStartup(); // call function sharkStartup()
}
if (onOffstate == HIGH)
{
digitalWrite(led, onOffstate); //Keep arduino LED 'on' as indication of mode arduino is in
digitalWrite(dePin, HIGH); // Hold dePin high when transmitting.
digitalWrite(dataSwitch, LOW);
sharkOnMode(); // Call sharkOnMode() to write joystick data to inverted serial bus
}
}
void sharkStartup () {
{
pinMode(dataSwitch, OUTPUT);
digitalWrite(dataSwitch, HIGH); // Flip data switch, HIGH = PNP 'Off', NPN 'ON'
delay(298);
digitalWrite(dataSwitch, LOW); // Flip dats switch, LOW = PNP 'On', NPN 'Off'
delay(10);
}
{
//build serial packet joystick manufacture info
data[0] = (0x74); // start identifier " t "
data[1] = (130); //
data[2] = (133); //
data[3] = (130); //
data[4] = (128); //
data[5] = (136); //
data[6] = (205); //
data[7] = (160); //
data[8] = (128); //
data[9] = (0x7F) - (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8]); //Checksum OK = (141);
data[10] = (15); // all packets end with this identifier
for (unsigned char i = 0; i < 11; i++)
sharkSerial.write(data[i]);
}
delay(16);
}
void sharkOnMode() {
{
yPotVal = analogRead(yPot);
delay(2);
xPotVal = analogRead(xPot);
yPotValMapped = map(yPotVal, 0, 1023, 128, 255) + 1; // Map min/max pot values to match min/max original Shark joystick values.
xPotValMapped = map(xPotVal, 0, 1023, 128, 255); // Map X values
}
{
// " ' " build serial packet - this is the packet i need to get the bit math right for the checksum
data[0] = (0x60); // Joystik packets start with this
/*data [1] and [2] are the only variables , declared as 'unsigned char' at the top
i have fixed values in the example below so i can work on the BIT Math with constants (because i did a data read)
and know what the checksum should be '191'
*/
data[1] = 192; //(yPotValMapped); // Joystick Y value 192 / neutral
data[2] = 191; //(xPotValMapped); // Joystick X value 191 / neutral
data[3] = 255; // Max speed setting via turtle/hare buttons on joystick
data[4] = 214; // 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] = (0x7F) - (data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7]) ; // checksum '191' if neutral
data[9] = 15; // all packets end with this identifier
for (unsigned char i = 0; i < 10; i++)
sharkSerial.write(data[i]);
}
delay(16); //Delay next packet 17ms input from Shark joystick
}
A one byte checksum, which is defined as 0x7F - ( least-significant 7 bits of ( sum of all data bytes and start byte))
Irving wrote:
- Code: Select all
byte sum = 0;
for(int i=0; i < 9; i++)
sum+=data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[9] = 0x7f - sum;
// " ' " build serial packet - this is the packet i need to get the bit math right for the checksum
data[0] = (0x60); // Joystik packets start with this
/*data [1] and [2] are the only variables , declared as 'unsigned char' at the top
i have fixed values in the example below so i can work on the BIT Math with constants (because i did a data read)
and know what the checksum should be '191'
*/
data[1] = 192; //(yPotValMapped); // Joystick Y value 192 / neutral
data[2] = 191; //(xPotValMapped); // Joystick X value 191 / neutral
data[3] = 255; // Max speed setting via turtle/hare buttons on joystick
data[4] = 214; // 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
byte sum = 0;
for (int i = 0; i < 8; i++)
sum += data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[8] = 0x7f - sum;
data[9] = 15; // all packets end with this identifier
for (unsigned char i = 0; i < 10; i++)
sharkSerial.write(data[i]);
}
Irving wrote:
- Code: Select all
byte sum = 0;
for(int i=0; i < 9; i++)
sum+=data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[9] = 0x7f - sum;
With help from
Lenny,
GizmoSmith,
Jim C,
and my very supportive wife, Naomi.
// This sketch is to emulate the packet of data that the Shark Joystick sends
/******************************************************************************
Author: Tony Matthews ammatthews at gmail dot com
License: FreeBSD
******************************************************************************/
/******************************************************************************
Copyright (c) 2015, Tony Matthews
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*******************************************************************************/
// This code is incomplete and still under revision.
// Its also got junk that may not be needed,
// Early testing phases.
// Names for Pins and what they are connected to
// getting ready to use GCDuiNode with the RF24 or Wii Nunchuck (currently hard wired)
// Pin outs for RS485 chip
const int onOffPin = 3; // Digital Pin for software on/off button
const int roPin = 11; // to RO of Max485
const int rePin = 10; // to RE of Max485
const int dePin = 9; // to DE of Max485
const int diPin = 8; // to DI of Max485
const int dataSwitch = 6; // Digital Switch for DG419
const int led = 13 ; // LED state indicator pin
//Boolean name holder for current state.
boolean onOffstate = LOW;
// Analog input pins assignments
const int yPot = A0; // Y Pot input value
const int xPot = A1; // X Pot input value
// Names for analogRead values of Analog Pots
int yPotVal;
int xPotVal;
// Names for Mapped analogRead Values of Pots
unsigned char yPotValMapped;
unsigned char xPotValMapped;
// Size of data packet, tho the packets are not constrained to this size.
// May need to change this value.
unsigned char data[12];
unsigned long timer = 0;
#include <SoftwareSerial.h>
SoftwareSerial sharkSerial (roPin, diPin, false); // 'true' sets this to invert software serial output.
void setup()
{
sharkSerial.begin(38400);
pinMode(led, OUTPUT); // Arduino led to monitor on or off state.
digitalWrite(led, LOW); // led staying on (very dimly) in off mode, not sure what thats all about
pinMode(onOffPin, INPUT_PULLUP); // Software on/off button, turn on internal pull up resistors.
pinMode(dataSwitch, OUTPUT); // Set Data switch pin to Output
digitalWrite(dataSwitch, LOW); //Start Data in LOW, Output still got heaps of noise, new chips coming to see if the old ones are the issue.
}
void loop() {
// Starts in Off state from physical power on.
// Check state, if "on" , "turn off"
if (digitalRead(onOffPin) == LOW && onOffstate == HIGH)
{
onOffstate = !onOffstate; //toggles onOffstate from HIGH to LOW (if it was HIGH when the on/off button is pressed)
digitalWrite(dePin, LOW); // hold dePin low when 'off'
digitalWrite(dataSwitch, LOW);
digitalWrite(led, onOffstate); // Turn off the LED on arduino as indication of state
delay (300); //debounce switch delay
}
// check state, if on/off button is pressed, change state to "ON" and run start up sequence.
else if (digitalRead(onOffPin) == LOW && onOffstate == LOW)
{
onOffstate = !onOffstate; // toggle state to HIGH if in'off mode' and on/off button is pressed
digitalWrite(led, onOffstate); // turn on LED pin to get visual indication of on/off state
digitalWrite(dePin, HIGH); // Hold dePin high when transmitting.
sharkStartup(); // call function sharkStartup()
}
if (onOffstate == HIGH)
{
digitalWrite(led, onOffstate); //Keep arduino LED 'on' as indication of mode arduino is in
digitalWrite(dePin, HIGH); // Hold dePin high when transmitting.
digitalWrite(dataSwitch, LOW);
sharkOnMode(); // Call sharkOnMode() to write joystick data to inverted serial bus
}
}
void sharkStartup () {
{
pinMode(dataSwitch, OUTPUT);
digitalWrite(dataSwitch, HIGH); // Flip data switch, HIGH = PNP 'Off', NPN 'ON'
delay(298);
digitalWrite(dataSwitch, LOW); // Flip dats switch, LOW = PNP 'On', NPN 'Off'
delay(10);
}
{
//build serial packet joystick manufacture info
data[0] = (0x74); // start identifier " t "
data[1] = (130); //
data[2] = (133); //
data[3] = (130); //
data[4] = (128); //
data[5] = (136); //
data[6] = (205); //
data[7] = (160); //
data[8] = (128); //
byte sum = 0;
for (int i = 0; i < 9; i++)
sum += data[i] & 0x7f; // 0x7f is same a ;s 0b01111111 but easier to write/check
data[9] = 0x7f - sum; //Checksum OK = (141)
data[10] = (15); // all packets end with this identifier
for (unsigned char i = 0; i < 11; i++)
sharkSerial.write(data[i]);
}
delay(16);
}
void sharkOnMode() {
{
yPotVal = analogRead(yPot);
delay(2);
xPotVal = analogRead(xPot);
yPotValMapped = map(yPotVal, 0, 1023, 128, 255) + 1; // Map min/max pot values to match min/max original Shark joystick values.
xPotValMapped = map(xPotVal, 0, 1023, 128, 255); // Map X values
}
{
// " ' " build serial packet - this is the packet i need to get the bit math right for the checksum
data[0] = (0x60); // Joystik packets start with this
data[1] = (yPotValMapped); // Joystick Y value 192 / neutral
data[2] = (xPotValMapped); // Joystick X value 191 / neutral
data[3] = 255; // Max speed setting via turtle/hare buttons on joystick
data[4] = 214; // 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
byte sum = 0;
for (int i = 0; i < 8; i++)
sum += data[i] & 0x7f; // 0x7f is same as 0b01111111 but easier to write/check
data[8] = 0x7f - sum; // if neutral joystick should read 191
data[9] = 15; // all packets end with this identifier
for (unsigned char i = 0; i < 10; i++)
sharkSerial.write(data[i]);
}
delay(16); //Delay next packet 17ms input from Shark joystick
}

gcebiker wrote:Still dont know what is causing the noise on data lines, but got a clean capture, checksum now working thanks to Irving, not far away now. Chair still not moving but i guess because i am sending the packets from the first microsecond of the Original SR....now to track down packets from when it actually kicks in and starts moving the chair.
Fun times...but have to work, Sailability Tuesdays, chiller repairs Wednesday, Aquaponics upgrades Thursday,
Wife Leaving me on Friday...for 10days on holiday![]()
So much stuff coming in the next week on order.
- Digi Spark Pro's + shields http://digistump.com/products/109
- 50 Dip 8 sockets , ebay
- 50 Max485 chips...thanks to a misread on the ebay listing.
- 10 DG419's from Element14
more protype boards then moving onto ordering boards online.
...i cant wait to actually be able to use the tilt actuator built into this chair i have not been able to move for years...
The money shot...Thank you all.
If power-supply sequencing is not possible,
add two small, external signal diodes in series with
the supply pins for overvoltage protection (Figure 1).
Finally all packets except for the Transmit Finished packet shall include a one-byte checksum, which is defined as 0x7F - ( least-significant 7 bits of ( sum of all data bytes and start byte ) ).
While the data format is 8 bits, bit 7 in each byte shall be used to indicate the first byte of a packet. Bit 7 shall be CLEAR (0) for
the first byte in a packet, and SET (1) for all other bytes. If there is a slight timing difference between the sending and receiving
modules, such that the receiver is slightly faster than the sender, having bit 7 set in the majority of the data bytes will give the
greatest chance of correct reception.
This means that each transmitted byte carries 7 bits of actual information.

While the data format is 8 bits, bit 7 in each byte shall be used to indicate the first byte of a packet. Bit 7 shall be CLEAR (0) for
the first byte in a packet, and SET (1) for all other bytes. If there is a slight timing difference between the sending and receiving
modules, such that the receiver is slightly faster than the sender, having bit 7 set in the majority of the data bytes will give the
greatest chance of correct reception.
This means that each transmitted byte carries 7 bits of actual information.
Finally all packets except for the Transmit Finished packet shall include a one-byte checksum, which is defined as 0x7F - ( least-significant 7 bits of ( sum of all data bytes and start byte ) ).
0x7F-(sum & 0x7F)
Return to Everything Powerchair
Users browsing this forum: emilevirus and 83 guests