June 5 - June 9
This week, I started testing the hall effect sensor in the main code for running the bogie. The interrupt created by the sensor worked half of the time. This was due to the fact that there were too many delay functions in the code. The delay function in the arduino IDE is a blocking function, which means that as long as the delay is running in milliseconds, everything else on the processor is waiting. Although interrupts are supposed to work during delay(), I observed that the variable in charge of detecting the magnet didn't change all the time.
To solve this, I replaced most of the delays (longer than 2 seconds) with if statements. These if statements did quick calculations of the time without holding up other processes and allowed optimization of the timing of the codes. However, another problem came up with the LCD keyboard shield and the Arduino Mega.
When the right button is pressed, it changed the variable that represented a magnet was detected, even though there wasn't a magnet present. This is problem for the switching mechanism because the arduino won't properly know if it's supposed to switch the steering arms or not. However, this isn't a big problem as long as we do not use the manual mode with switching. For example, we only manually drive the bogie up the sloped track, and back down the sloped track.
Finally, I found limit switches in the shop, and started testing them and learning how to wire them correctly. Next week I will connect all eight limit switches and check if they change the booleans of the steering arms. These booleans check if the right or left arm is properly engaged when either all right or left switches are pressed. When the booleans are checked and the magnet is sensed, then the stepper motor will turn the arms in their correct position. In the future, I need to check the pin connections from the arduino to the H-bridges in order to control the motors correctly.
No comments:
Post a Comment