Im stumped on this one...the program is for a little Picaxe 14m2-driven controller that controls the transmission torque converter on an engine dyno. (not in a vehicle, just on a stationary dynomometer stand/room)
It works perfectly, one button to lock the converter, one to unlock, and then a third button activates an "automatic" mode that automatically locks the converter when throttle position gets to 100% (measured with the Picaxe ADC).
However I wanted to add the capability of "on the fly" fine-tuning of how "harsh" the converter lockup is (IE, how fast the Picaxe ramps up the PWM from 0% to 98%), without having to reprogram the Picaxe chip with my computer.
So I taught myself how to use the EEPROM/read/write functions of the Picaxe. I also wrote two different "harshness" (PWM ramp up rates) routines in the program. So when you press the "LOCK" button, it will jump to 1 of the 2 "harshness" routines. What determines which routine the Picaxe will follow is set by my "program" feature.
What I have setup is so when you turn power on to the Picaxe while holding the "LOCK" button (Pin C.5), the Picaxe will read this and enter a "program" mode...it will signal that the programming mode has been entered by flashing a blue LED and a red LED alternately in rapid fashion...then after the LED's stop flashing, you can press either the "LOCK" button to select the "aggressive" PWM ramp-up, or the "UNLOCK" button to select the "soft" PWM ramp-up. Once you have pressed either button, the red LED or the blue LED will light up for a second confirming your choice, and then it will write that "choice" to the EEPROM, and then return back to the start of the program and function as normal. So basically now each time you power it down and power it back up again, it will have that "choice" (harsh or soft PWM ramp-up) saved in EEPROM, it will read the value, and then use that saved setting from now on so whenever you press the "LOCK" or "UNLOCK" button, it will use either the harsh or soft PWM ramp-up rate.....and it will keep/use that ramp-up rate until you manually enter the programming mode again and change the setting.
The problem is that in the simulator, when you start the program with the button held-down, it starts acting totally erratically. IE, Pin B.0 starts going high for absolutely NO reason...Pin B.1 and Pin B.3 also start turning on and off when they want to, etc.. You can clearly see the program scrolling through in the simulator, and the Output Pins on the Picaxe clearly are doing different things than what the program is actually saying.
I copied and pasted the first portion of the program into a new file, and it seems to work fine??????? I cant possibly see how something further down in the "long/full" version of the program is messing with something, because it starts acting all wacky before it even gets to the rest of the program.
I know my code is clunky and totally amateur/could be made better in so many ways, but it worked perfectly (up until I tried to add this clever 'self-program' utility into the program) and now I cant figure out why or what is causing the Picaxe to act erratically. Ive attached a video so you can see the two similar programs operating...and how the [long] program doesnt even follow itself properly/logically.
thanks for any advice/help on the issue.
Ben
http://www.youtube.com/watch?v=Vwzi_Si6-nI
It works perfectly, one button to lock the converter, one to unlock, and then a third button activates an "automatic" mode that automatically locks the converter when throttle position gets to 100% (measured with the Picaxe ADC).
However I wanted to add the capability of "on the fly" fine-tuning of how "harsh" the converter lockup is (IE, how fast the Picaxe ramps up the PWM from 0% to 98%), without having to reprogram the Picaxe chip with my computer.
So I taught myself how to use the EEPROM/read/write functions of the Picaxe. I also wrote two different "harshness" (PWM ramp up rates) routines in the program. So when you press the "LOCK" button, it will jump to 1 of the 2 "harshness" routines. What determines which routine the Picaxe will follow is set by my "program" feature.
What I have setup is so when you turn power on to the Picaxe while holding the "LOCK" button (Pin C.5), the Picaxe will read this and enter a "program" mode...it will signal that the programming mode has been entered by flashing a blue LED and a red LED alternately in rapid fashion...then after the LED's stop flashing, you can press either the "LOCK" button to select the "aggressive" PWM ramp-up, or the "UNLOCK" button to select the "soft" PWM ramp-up. Once you have pressed either button, the red LED or the blue LED will light up for a second confirming your choice, and then it will write that "choice" to the EEPROM, and then return back to the start of the program and function as normal. So basically now each time you power it down and power it back up again, it will have that "choice" (harsh or soft PWM ramp-up) saved in EEPROM, it will read the value, and then use that saved setting from now on so whenever you press the "LOCK" or "UNLOCK" button, it will use either the harsh or soft PWM ramp-up rate.....and it will keep/use that ramp-up rate until you manually enter the programming mode again and change the setting.
The problem is that in the simulator, when you start the program with the button held-down, it starts acting totally erratically. IE, Pin B.0 starts going high for absolutely NO reason...Pin B.1 and Pin B.3 also start turning on and off when they want to, etc.. You can clearly see the program scrolling through in the simulator, and the Output Pins on the Picaxe clearly are doing different things than what the program is actually saying.
I copied and pasted the first portion of the program into a new file, and it seems to work fine??????? I cant possibly see how something further down in the "long/full" version of the program is messing with something, because it starts acting all wacky before it even gets to the rest of the program.
I know my code is clunky and totally amateur/could be made better in so many ways, but it worked perfectly (up until I tried to add this clever 'self-program' utility into the program) and now I cant figure out why or what is causing the Picaxe to act erratically. Ive attached a video so you can see the two similar programs operating...and how the [long] program doesnt even follow itself properly/logically.
thanks for any advice/help on the issue.
Ben
http://www.youtube.com/watch?v=Vwzi_Si6-nI