Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Firmware Edits #4

Closed
helm-hammer-hand opened this issue Jun 10, 2013 · 0 comments
Closed

Some Firmware Edits #4

helm-hammer-hand opened this issue Jun 10, 2013 · 0 comments

Comments

@helm-hammer-hand
Copy link

When testing out the BrickPi i ran into two issues:

  1. whenever i called readAnalog after calling SetMotor the values came in out of order.
  2. nothing happened the first time i called setMotor or ReadAnalog

to fix 1: in firmware_2_0 the first line of the function parse_string_data() is: Serial.print(inputString[0]). every time something is sent from python to arduino it then sends back a character which is then left on the buffer to be read by the next (unsuspecting) function. delete that line.

to fix 2: when python starts on the raspberry pi it sends a character '\xf8' to the buffer. This causes inputString[0](in firmware_2_0) to be that character instead of the character corresponding to the correct case of the switch in parse_string_data(). this can be handled by putting a case statement at the beginning of parse_string_data to determine if the startup character has been sent. i put the code i used below:

if(inputString[0]=='\xf8') {
for(int i=1; i< inputString.length(); i++) {
firstRun+= inputString[i];
}
inputString= firstRun;
firstRun="";
}

A few other small changes i made:

  1. I changed the i changed the python motor function to be of the form: SetMotor(motor_number, motor_speed) in both the firmware and python library.
  2. I added a case 9 to parse_string_data to handle the python function SetAllMotors(motor_speed) i created to set all the motors to one value.
  3. i changed the python ReadAnalog() function to take in a port number and return the int value of the sensor in that port.

I can send you my edited versions of the firmware and BrickPi2.py if you'd like to take a look.

CLOSING THIS ISSUE AND OPENING UP INDIVIDUAL ISSUES FOR EACH PART. New issues can be found at:
#6 (Fix for ReadAnalog() values coming out of order after calling SetMotor() in BrickPi2.py)
#5 (Fix for nothing happening the first time ReadAnalog() or SetMotor() are called in BrickPi2.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant