a couple of things then off to bed.
Some time ago, I know not when, I purchased PIC MICROCONTROLLERS from MikroElektronika. Then I put it in a pile and forgot. It reappeared this morning. Looks like I have much of the ASM info I have been seeking.
My old HPWM system uses a TRIGGER: subroutine for SONAR triggers. The leds on the SONARs blink many times per second. They are too fast to count accurately. Each SONAR blinks at least 55 times in ten seconds. My non-mathematical guess is fast's enough if the steering servo and the wheel motor are reacting 'instantly'. Which they are not.
I think I have learned that there is no advantage keeping the PWM signal down to 50hz. All that is necessary is to calibrate the pulse widths as they appear in HPWM 2, xx, 50.
envisioning my variables?
A number of your suggestions push me to work quantitatively. I have been 'eying' my distances - measuring with outstretched hand tip of thumb to tip of little finger = about ten inches.
I would have a better handle on the behavior of my robocar if the SONAR measurements were in decimal inches. Right now I have a system of translating the echo pulse size to inches that I derived empirically. It would make my life easier if when I do a READ of numbers I have stored in EEPROM Data they came out as digital. How with PBP do I do that?
What I have been thinking.
I have been multiplying by .066 (in my head). Give or take a decimal point. I want to be able to READ the EEPROM and see inches. Not easy?? Is there a PBP routine that does this?
My interrupts are once every 5 millisec. I count 25 of them between each SONAR trigger. They are 125 millisec apart. The servos do work well with properly timed pulses, but they do not seem to react any quicker or with any finer precision. I have no accurate means of measuring this.
Thank you for thinking along with me. My computer experience was all digital data communication. Ultimately I retired from CISCO. I know nothing about real time control systems.
Ken
New video. Model car races Toy car
Today I brought both of my PIC controlled cars to the old gym to see how they fared together on the same track. Here's the video. Which do you think was the winner? Remember the TOY car is red. The MODEL car is blue. The TOY cost originally cost $50. The MODEL cost $200. Both have my kit.
http://www.youtube.com/watch?v=7Bw-svW1n3Y
What do you think? Should I show it on Access Television?
Ken
Potential solution to bang-bang steering
I have a new plan to control the much faster 1/10 scale toy car which is fast, but does not contain proportional controls. The trick is to turn the wheels only for a short period of time (150 msec at the moment) then 'kick' (supplement the springs) them back to neutral.
If the neutral is well calibrated (the 1/10 cars have a knob that centers the wheels) this method makes the car turn with little swerve. I need this while wall following. Otherwise the car crashes into the wall before the code/DPDT relay/steering wheels can react.
I'll make a video if this really works.
Ken
Your full size scale car has toe in and caster....
My toy car has neither toe in nor caster. But it should be able to react. It does not. If you are in a helping mood here is both a (disappointing) video, and a pointer to my code.
http://www.youtube.com/watch?v=ykn8MkGDm28
http://www.employees.org/~kjones/ToyCarKickTurn3.htm
Could the PIC be resetting? Am in a looping loop? The whole thing is only 503 words compiled. My guess is that I am not seeing something that right in front of my eyes...
Ken
Seems to work OKAY on the bench
Went to bed last night puzzled.
Checked the car (untouched since disastrous demo yesterday) on the bench. Seemed to react correctly and quickly. The stimuli are my hands moving as quickly as I can make them.
Hmmmm.....
This must be the looping triggers section
Could it be that somehow this tight loop eliminates the ability to react to the front SONAR. The video shows the car stuck against the wall in total silence with the front LED constantly on. This WHILE loop could cause that if somehow the two drive motor instructions were being short changed. Maybe I need a PAUSE in here. It would do no harm.
Code:
keepreversing:
WHILE rangefront < stopreversing
' We have not reversed far enough
HIGH stopgo 'go
LOW forrev 'back
GOSUB triggers
WEND
I'll share the code in a bit
The changes were of two types.
1. Instead of "braking" by turning off the DC voltage to the wheels (thereby relying on reverse polarity created by the rolling momentum of the wheels in the DC motor) I now use the DPDT relays to reverse the polarity for a few hundred milliseconds.
2. I put some PAUSE commands in to make sure wheel and steering related commands had time to actually do what I had expected.
Thanks...
Ken
The break through was in fact a break -er it was broke!
I put the car up on blocks and found that when going forward it only turned left in my patented incremental way. It also flashed the SONARs at about 1/2 the usual rate.
The Vcc wire for the right side SONAR had become disconnected.
Soooo with the front SONAR working and the right SONAR always saying zero distance to the wall, the car turns left in little bits except when it approaches a wall head on. Then it brakes and swerves left.
That's exactly what my video shows.
Given that information, what if anything should I fix?
Ken
It is beginning to dawn.....
The issue is controlling the steering. It is bang-bang but I can modify the length of time and the frequency of each 'bang'. The plastic wheels slide easily. This is true of turning as well as forward or reverse drive.
I hope not to introduce an adjustment POT. It appears that the plastic mechanical parts are not consistent. Kicking the steering wheels back from full reach seems not to be symmetric. Hmmmm. :(
Ken
I did as scalerobotics suggested and
it worked better. Now it goes pretty straight but does not turn left hard enough when confronted with a corner. Watching and listening to my video I conclude that at this speed with this little friction the PIC needs more warning (I only gave it 53 inches) to turn sharply left. I'll change that and try again tomorrow. Also this sharp left turn should not be modulated. It should be bang.
It is a bit of a drive to my deserted gym. It has no heat and no electricity. My laptop crashed a few weeks ago. So one fix on my desktop PC, one test.
A question: Do you folks recommend any editor that automates my version control? I would like to start with version 1.0 then activate an editor that automatically adds each of my code changes one batch at a time. If I had that I could recreate any past version.
Presently I am saving the versions identified by their checksum. That is clumsy.
Ken
How do you keep track of the changes?
How do you keep track of the details of each change? Comments grow and grow and grow...