Well this is exciting Gareth is Clang Clang Clang at adding another micro-controller to the MRL BORG !

Cheat Sheet for all the Command Possibilities ? 
Yes, MRLComm.ino would be the best source... or the Arduino.java file

the send & recieve protocol is : - each value is a single byte

 MAGIC_NUMBER|NUM_BYTES|FUNCTION|DATA0|DATA1|....|DATA(N)

 

#define MAGIC_NUMBER    170 // 10101010

 

This is the core Arduino part - sending a message to the computer

Serial.write(MAGIC_NUMBER);
Serial.write(3); // size
Serial.write(DIGITAL_VALUE);
Serial.write(digitalReadPin[i]);// Pin#
Serial.write(readValue); // LSB
 
 
This is the core Arduino Service part on the computer sending a message to the Arduino
 
 
                       serialDevice.write(MAGIC_NUMBER);

			// msg size = function byte + x param bytes
			// msg size does not include MAGIC_NUMBER & size
			// MAGIC_NUMBER|3|FUNCTION|PARAM0|PARAM2 would be valid
			serialDevice.write(1 + params.length);

			serialDevice.write(function);

			for (int i = 0; i < params.length; ++i) {
				serialDevice.write(params[i]);
			}

 

 

Cheat sheet of function numbers (in MRLComm.ino)

 
#define DIGITAL_WRITE        0
#define DIGITAL_VALUE        1
#define ANALOG_WRITE         2
#define ANALOG_VALUE         3
#define PINMODE              4
#define PULSE_IN             5
#define SERVO_ATTACH         6
#define SERVO_WRITE          7
#define SERVO_SET_MAX_PULSE  8
#define SERVO_DETACH         9
#define SERVO_STOP_AND_REPORT 10
#define SET_PWM_FREQUENCY    11
#define SET_SERVO_SPEED           12
#define ANALOG_READ_POLLING_START 13
#define ANALOG_READ_POLLING_STOP 14
#define DIGITAL_READ_POLLING_START 15
#define DIGITAL_READ_POLLING_STOP 16
#define SET_ANALOG_TRIGGER               17
#define REMOVE_ANALOG_TRIGGER            18
#define SET_DIGITAL_TRIGGER              19
#define REMOVE_DIGITAL_TRIGGER           20
#define DIGITAL_DEBOUNCE_ON              21
#define DIGITAL_DEBOUNCE_OFF             22
#define DIGITAL_TRIGGER_ONLY_ON          23
#define DIGITAL_TRIGGER_ONLY_OFF         24
#define SET_SERIAL_RATE         25
#define GET_MRLCOMM_VERSION 26
#define SET_SAMPLE_RATE 27
#define SERVO_WRITE_MICROSECONDS 28
#define MRLCOMM_RX_ERROR 29
 
Error Checking
 
Currently the way both sides behave - if they do not get a magic number at the expected start of a message they throw out the bytes until a magic number is found.  They also send a RX error message if this happens.

Gareth

10 years 6 months ago

Thanks for the info Greg .......that will do nice_ly.

Code name :-  GroGoProP

All is going along neatly .... just securing which Serial Object fits best...

Looks like i can wind the speed up to 115200 Baud, (not sure if i can sqweeze more speed until code is progressed).

I will dedicate one of the propellers COGs to service the Serial data meaning its free running in the background, and the main Propeller code will extract and reroute the important bits.

Plan is to attach an ADC Chip  giving 8 analogs and then the rest can be set aside for digitals or PWM signals..   Then mapping the result to match as close as possible to the arduino....meaning that the other services written for the Arduino will also tie in seamlessly.

....Well thats the plan.......

Regards G

WOOOHOOO !

Bravely lead on Sir Gareth ! ..  um somewhere around I might even have an old Propellor .. if I can dig it out mebbe I can follow some of your most excellent Parallax-Fu