Things are going a bit better
I have not yet had to fall back on ASM code.
I did discover:
1. My PIC was resetting because of regressive subroutine calls. Changing a couple GOSUB's to GOTO's solved that.:)
2. My car was not being driven smoothly because of occasional zero responses from the SRF05's (or at least one of the SF05's). Implementing a - check again if the sensor says zero - routine after polling the sonar sensors smoothed things out.:D
I did notice that adding an IF THEN statement to the PBP code increased the size of the HEX code considerably. I still feel I need to understand the two compile processes.:(
Frustration, thy name is speed.
Not going well at all.
When I up the speed the car does not respond quickly enough. At a corner Instead of seeing (hearing) ahead and turning, it crashes into the on coming wall, backs up, and tries again. Part of my problem is not understanding the machine language code behind the PICBASIC PRO commands. Another part is the PIC getting into little loops or resetting and thereby ignoring the real time signals. Lastly I need to expand the distances to which the code reacts. If the velocity is greater, it must start turning or braking sooner.
On the bench, the machine seems to behave as expected, but on the race track. NOPE.:mad::confused:
Ken
It surely did change the behavior.
Bed time here on the east coast.
I tried both
OSCCON = %01110111
and
OSCCON = %01110001
I got the PIC to read the PWM signal from the radio channel 3 by doubling the threshold for differentiation. I can toggle between PIC and radio control.
But I have not been able to get the HPWM to behave. I tried using the original duty cycle. This made the wheels go backwards very fast no matter what was in the HPWM command. I tried doubling the duty cycle (to account for cutting in half the clock rate and the wheels did not turn at all. The Electronic Speed Control wants this PWM signal to arrive at 50 hz. In fact it is probably at 489Hz (according to page 87 of MicroEngineering Labs' PICBASIC PRO book). I'll put a 'scope on it tomorrow.
I think the book says that HPWM channel, 127, 50 will be a square wave of 489Hz. Does that agree with you guys' thinking?
I also have not gotten the PING echos to mean anything. The little red lights on the SRF05s are blinking. But my code is not making sense of the echo responses. I thought that all I would need to do was to double the expected echo pulse duration numbers.
Ken
1 Attachment(s)
PWM per Electronic Speed Control specs.
Originally Posted by Kenjones1935 View Post
The Electronic Speed Control wants this PWM signal to arrive at 50 hz.
I was not clear in my last posting. The Electronic Speed Control PWM specification is for a single positive pulse no less than 1ms and no more than 2ms once per 20 ms, ie 50 pulses per second. The one to two millisecond pulse width is divided into 256 parts. 1.5 ms corresponds to 128 which corresponds to neutral in a servo.
Neutral is steering straight on a steering servo. Neutral is stopped on a wheel driving servo.
I discovered that using HPWM with the 4mhz default oscillator a pulse width of 100 to 110 gets the behavior of 'neutral' on my car. For example "HPWM 1, 100, 50" turns the front wheels of my car to straight. See the attached picture. Channel 2 is the HPWM version of neutral. Channel 3 is what the radio receiver sends.
Ken
Progress - er, at least using my head.
I have found a way to make short, 10 to 80 usec pulses while using the 4mhz oscillator. The SRF05 proximity detector wants at least 10 usec. If I give it super long pulses catching the following echo measurement can be a problem for PULSIN.
Sooo the following makes an 80 usec positive pulse.
SYMBOL trigright = PORTB.0
LOW trigright
HIGH trigright
HIGH trigright
HIGH trigright
LOW trigright.
One thing at a time.
Ken
No, but I never thought about echoing echos
I've added a PAUSE of 1/10sec between the front trigger and the side trigger. This noticeably slows down the flashing of the LEDs on the SRF05s. In the audible range I can easily hear echos in a room. I have no experience with ultra-sound in the range that the SRF05 emits. The spec shows a time line in which the pulses seem to be a square wave of 2usec cycles. That is a little burst of 500,000 cycles per second sound that appears to last about 20 usec.
This little project keeps gets interestinger and interestinger!:D:D
If there were five cars racing near each other on this gymnasium track, would their SRF05's get confused. I don't think so, but I am not sure....:o
Ken
A product suggestion would be greatly appreciated.
If I went with IR proximity sensing, the reflections would be from brick, wood and cardboard. Distance one to five feet should do it. Any suggestions?
Ken
Things are not simple any more
Today I took some cardboard boxes to my gymnasium race track. I arranged them in the middle of the floor about six feet from the walls.
The car did not behave as expected. It is futile to try to describe what it did. I shall video tape it (probably not for public consumption) and try to analyze what is happening.
The SRF05 flashing LEDs are constantly illuminated. That should be good.
My present code has only two 'regular' states.
1. Going forward being guided by the side looking SRF05. The forward pings are monitored for something close enough to merit turning hard left while still going forward.
2. Going backward and turning to the right because the front looking pinger sees something too close. The backward state is left by either timing out, or by the forward looking pinger saying that the obstruction is no longer there.
With the car on blocks and me manipulating a large piece of card board, the wheels move true to concept. In the gym was something else.
Interesting stuff, real time control code. I made my living in data communication hardware and software development. Nothing actually 'moved' in the common sense of the word.
Ken
A youtube video. Not very enlightening...
I made this video of my car on my "race track"
As I speed up the car the behavior becomes less consistent.:confused:
Take a look see if you like. It's only a couple minutes long and the car does work correctly sometimes.
http://www.youtube.com/watch?v=bx8KKDknAx0
Ken
I may have to add another SRF05
I think a big part of my problem is peripheral vision (hearing) of the front
sensors. As the car sped up I had to increase the frontdanger threshold. Now if the car gets turned a little to the left while running down the straight
it 'sees' the cardboard and turns left thinking that it is coming to the
corner. Solutions?
The simple one is to place the cardboard further away from the side wall.
I could rewrite the code so that hard turning left only is allowed when close to the side wall. Trouble with that is if the car ever got free in a room it would crash straight into walls.
I could add left side SRF05's. That would make staying in the middle of the lane easier and minimize the effect of peripheral hearing.
What do you all think?
Ken
I added a port side sonar
I have added a left looking SRF05. This gives the car great new autonomous potential. I shall stick to the first problem first. Disappear behind a card board wall and come out the other end at speed.
My first thought is to stick to the path half way between the solid wall and the card board wall using the right and left sensors for guidance. If I can keep the car pretty much following that line without oscillating then once the front echo says, "DANGER", the car will know that it must be approaching a corner.
Algorithm suggestions are welcome.
Ken
I added a left hand side sonar sensor
I think this video does a pretty good job of showing the potential of this PIC controlled car.
http://www.youtube.com/watch?v=KDUWyGh8eIo:)
With the three sensors this car might be able to negotiate a true maze.
What do you think?
Ken
Potential problem with interrupt driven PWM
I need the correct PWM signals to be going to the wheels (Electronic Speed Control) and to the steering (servo) at all times.
I have programmed a PAUSE 500 to guarantee sufficient time for the car to back up out of trouble after hitting a wall.
Am I correct is thinking that since PAUSE 500 is not re-entrant my interrupt driven PWM pulses will not occur for that 1/2 second? The car will not back up as planned.
I need to turn my PAUSE into a time consuming DO LOOP. True??
Ken
Hello again from autonomous-RC-car-negotiating-a-maze land
Sorry, folks, I've been distracted trying to figure out how to "kit" this "educational tool" (toy). The Microchip PICKit2 board only costs $23.99. It has a small surface mount proto area. I do not understand how to make use of it. I need to mount my Zettler relay and my TI sn7407n plus a bunch of mini EMS connectors for the radio, the three SRF05's the steering servo and the electronic speed control. sssissshhh!
Today I eliminated the need for channel 3 on the radio system. Which is very good cost-wise. Regular Ready to Race hobby cars come with only two channels on their radios. Adding the third is quite expensive. The PIC can know it is inside a maze given input from three proximity sensors. If there is something close to the right and to the left then it must be in a maze. The first run of this new algorithm showed it flawed. The PIC thinks it is out of the maze when it comes to a corner.
Back to the drawing board. Any suggestions?
Ken
This I'm-in-a-maze automatic detection mechanism is not going well
My first attempts at toggling between PIC and Radio control automatically have not gone well. I figured that the PIC could know from the proximity sensors that it was inside the maze. There seems to be too many variables.:rolleyes:
If I were to use a light sensor to distinguish, which sensor and at what wave length makes sense. Remember I am imagining the cars to be racing - going fast even in the maze. This set up would be in a middle school gymnasium - a basketball court maybe. If I could imagine making a maze out of BIG cardboard boxes with roofs I could use simple light detection. But I don't see how to make that elaborate a maze. Is there a light detector that does not see ordinary ambient indoor lighting, but does see some kind of special light source? Could I run a string of these light sources the length of the maze? Inversely I could run a string of these light sources outside the maze where the cars would see them.
Thanks for your attention.
Ken
Yes, the IR beam is sounds correct.
I've been having trouble testing this new feature. First, the car behaves as if there is noise in the SFR05 responses. I have no idea if that is truly the case. The car toggles when I don't think it should. AND when that happens it takes off on its own. It is way too fast to catch It dodges all around in inside my garage. When I used channel 3 I had an over ride. Not now. (even as I write I ask myself why not, for testing purposes, reactivate channel 3) Dumbo - of course!:cool:
I like the IR beam idea. How do I implement that? Do I purchase a heat lamp? Is that the IR wavelength that the sensors recognize?
Ken
How about a simple photocell to toggle
How's this sound. Two 100 watt bulbs inside reflectors. One mounted close to the beginning of the maze and the other at the end of the maze. I think I could get a standard photocell to detect the difference between that light intensity and ambient room level. The rule for the PIC would be, "See the light, TOGGLE."
Here's the spec for the PHILMORE photocell 10807:
Quote:
"A typical use is for switching on lighting after dark. These are also used in alarm systems, exposure meters, flame detectors, opto-couplers etc. This cell has a dark resistance of 5,000 ohms and 300 ohms in bright light (100 cds. or more)."
If this technique were used in my car an emergency TOGGLE device would be a powerful flashlight.
What do you think? I have the 10807's. I think I need to experiment. An old fashioned Triplett multimeter should to the trick.
On the old subject of oscillations. These were oscillations in the motion of the car. They were caused by my not correctly selecting the thresholds on the SRF05 proximity detectors. I felt I solved that.
The idea of a WHILE WEND loop is a good one. I sort of do that already. The PIC triggers the SRF05's many many times per second. My car continues to do one thing until the three echo pattern changes, then it does something else. If there is a bit of noise in one set of readings, it is smoothed over by the next set coming in a few milliseconds. I do not have an error signal.
When I first read Ioannis' PID suggestion I thought of a PID system based on position of the servo. My mistake. He is really suggesting that I devise an error signal to minimize. I gotta think more about that.
Ken