You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing out the BrickPi i ran into two issues:
whenever i called readAnalog after calling SetMotor the values came in out of order.
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:
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.
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.
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)
The text was updated successfully, but these errors were encountered:
When testing out the BrickPi i ran into two issues:
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:
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)
The text was updated successfully, but these errors were encountered: