Beginning to see the light...
OKAY,
With the help of the new-to-me oscilloscope I saw what I had been suspecting. The PIC's HPWM signal is not structured like the RC receiver signal. This explains why the PIC has not been able to command a smooth gradation of steering servo positions or wheel driving torque.
The RC receiver produces a pulse every 20 milliseconds (50 Hz). The pulses are between 1 and 2 milliseconds long. The PIC's HPWM machine produces a pulse every 3.8 milliseconds (263 Hz). The pulses are between 1 and 2 milliseconds long.
This matches scalerobotics comment of yesterday. It also matches the PBP textbook. Now that I understand what it is saying.
What I have does give me steering and wheel drive control. It is more bang/bang than I would like. It goes FAST. Which leads me to the problem of getting the car to steer left soon enough when approaching a corner in the wall.
The RC versus PIC control toggle works. Under RC control the car reacts like the original system. RC channel 3 provides the toggle signal. The PULSIN command does a fine job differentiating short from long PWM on this incoming signal. The code then controls the AZ8222 Subminiature DIP DPDT Relay via the SN7407N DIP MOS driver. This DPDT switch selects either the PIC output or the RC receiver output to send to the electronic speed control and the steering servo.
I'll make a video when I get the kinks out. I am afraid my prototyping technique is not robust enough to withstand the bumps needed to straighten out the feed back loops.
Thanks again for your help and encouragement. :)
Ken
What I do not understand is......
Here is a video of my RC car taken today at our Radio Control Hobby Shop's race track.
http://www.youtube.com/watch?v=seDKRDUdehE
Why does my code take so long to see and react to the information from the proximity sensors? :confused:There are no long PAUSE statements in my code. I am using HPWM to create the PWM control signals. Maybe I should take all the comments out of my code and post it for your consideration.
Ken
1 Attachment(s)
Here is a foreshortened code version
Here is my code as seen by WINDOWS notepad application. It does not make the PBP commands into capitals.
Were is the big delay?
Ken
I living under a misconception
I thought that a PIC runs at micro second speed. I thought that a loop clean through all my code would be indistinguishable by my human eyes.
The SRF05 have little red lights that flash each time they are pulsed. While the PIC is running the little flashes come about one per second.
How can that be? What is consuming the time?
Where can I get some information about the relation between PBP commands and real 16RF887 machine language code?
Ken
I sped things up a bit.....
Inline code is probably faster than subroutine based code. I commented out all the HPWM subroutines and substituted in place of their calls the HPWM statements themselves.
My guess is that the SRF05's are blinking faster. That is very good.
I checked the SRF05 responses. They seem to be immediately after the one millisecond trigger pulse. PULSIN should not be timing out, but that is a vulnerability worth considering.
Ken
PULSIN is part of the problem!!
I did a DEFINE PULSIN_MAX 1000 and the car is falling into my 'failed' because 'rangefront' or 'rangeright' equals zero. Interesting!! Something there is not consistent.
Voltage supply seems to make a difference
When running independently off the 7.2v voltage regulated battery the SRF05's seem more consistent with their responses than when running off the PIKkit2 USB provided 5volt supply. Interesting if true.
Thanks again, all...
Ken
It gets interestinger and interestinger....
Added complexities. Classic amateur robot stuff I would guess.
1. The sonar proximity detectors have a fairly wide field of "vision". If the car bumps against the side wall at a sharpish angle, the front detectors see the wall. The program thinks the car has come to a corner in the room and makes a maximum sharp left turn. This sets the car up for a very zigzag pattern.
I tried making a "megaphone" for the front sonar pingers out of the cardboard tube on a toilet paper roll. The sonar "detected" the tube. Hmmmm
2. When the battery begins to fade the car has a difficult time moving from a dead stop. Given a nudge, it takes off. The net behavior becomes quite different. Discombobulating to say the least.
3. The wheels and the steering servo still appear to be reacting too slowly. Exactly what is the problem is not clear.
That is the report for today...
Ken
Still the car responds too slowly
I am thinking that I need to better understand 16F887 machine language to make real progress. Certainly if I were to code in Assembly I would have a better feel for which macros take more time than others. I have not paid any attention to this until now.
This morning I looked at the ASM command list. I noticed that ASM has both a CALL and a RETURN command. This makes PBP's GOSUB and RETURN inexpensive I would think. Getting rid of subroutines will not improve speed.
I also note that PBP's IF, THEN, ELSE, ENDIF do not match straight into ASM code. Maybe I should write these case specific in ASM instead of PBP.
Somehow I have to speed up my processing loop.
Any suggestions?
Ken
OKAY, I got one problem solved...
You all suspected my usage of PULSIN.:rolleyes:
You were correct.:D
To determine whether to take control itself or let the radio receiver do its thing, my PIC must read the PWM code from the radio receiver channel 3. That PWM comes in only fifty times per second.
I was asking PULSIN to measure that pulse without setting an interrupt for when it sees a rising edge. What are the chances of my PULSIN moment (plus delay waiting according to pulsin_max) seeing something happening only 50 times per second. Answer, not good.
What are the chances of my PIC seeing that pulse when the radio transmitter is not powered? None whatsoever!
So: When testing my car up on blocks in my "lab" and not remembering to turn on my radio transmitter the poor thing spends 99% its time waiting for a pulse that never arrives.
Yep. Turn on the transmitter (even with channel 3 in the autonomous control position) and my SRF05 blinkers flash like crazy. They are being continuously triggered.
I still have a problem with response time, but it is not because the PIC is lacking sensor information.
Ken
1 Attachment(s)
Here's the code that's in the video
I don't think I have changed anything other than remove confusing comments.
Ken
The car is working much better...
Here's a video of our car running a hall in our house.
http://video.yahoo.com/watch/7164676/18657928:D
I moved the front sonic sensors closer to the front of the car and I figured out how to slow down the wheels a bit.
Next thing, I think, is to build a better looking and stronger prototype using a car with more room to attach stuff. What other kinds of sensors should I try and what other kinds of tasks will they help the PIC do?
Again, thank you for all your interest and help.
Ken
How about a line follower?
Been thinking that a good middle school STEM hook would be simple racing on an oval indoor (gymnasium basketball court) track delineated by large cardboard boxes (big enough to be detected by the SRF05 sonar proximity detectors) on the inside. I imagine a ten lap race. For six laps the kids control the cars with their radio transmitters. For four laps the cars are autonomous.
I think I can design a PBP template that would make coding the PIC reasonably simple. The template would contain the code state machine. The students' job would be to choose the steering/wheels commands associated with each state.
I have a question for you all.
If I were to add a black tape line around the track, what electronic gimmick might I put on an RC car to make it into a line follower? Is there a commercially available light source and photo cell combo similar to the pre-canned SRF05 sonar device?
Ken
Oops! ioannis I had forgotten what's in a ESC
I just realized that the innards of an Electronic Speed Control device is a servo driven potentiometer. In the old days these were actually mechanical pots but today my guess is that they are completely electronic (however that can be)
If I am wrong on this, please set me straight. What is a modern ESC?
Ken