I made this video of my car on my "race track"
As I speed up the car the behavior becomes less consistent.
Take a look see if you like. It's only a couple minutes long and the car does work correctly sometimes.
Ken
I made this video of my car on my "race track"
As I speed up the car the behavior becomes less consistent.
Take a look see if you like. It's only a couple minutes long and the car does work correctly sometimes.
Ken
I want to use the interrupt system to make my Pulse Width Modulated pulses output at 50hz. I am hoping that will give me finer control of the wheel speed and maybe a quicker steering response.
I understand that I need to preset TMR1 with a number so that it rolls over every 20 ms. thereby triggering the interrupt. How do I figure out what that preset number should be and how do I set it using PBP?
Ken
Looking at the datasheet:
With a 4MHz clock, (TMR1H:TMR1L) increments every 1uS. To generate an interrupt every 20mS, you want it to count 20,000 - so preload (TMR1H:TMR1L) with 65535-20000 = 45535 or FFFFh-4E20h=B1DFh.6.7 Timer1 Interrupt
The Timer1 register pair (TMR1H:TMR1L) increments
to FFFFh and rolls over to 0000h. When Timer1 rolls
over, the Timer1 interrupt flag bit of the PIR1 register is
set. To enable the interrupt on rollover, you must set
these bits:
• TMR1ON bit of the T1CON register
• TMR1IE bit of the PIE1 register
• PEIE bit of the INTCON register
• GIE bit of the INTCON register
The interrupt is cleared by clearing the TMR1IF bit in
the Interrupt Service Routine.
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 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
You do have oscillations don't you?
Well, the best way to avoid them is the PID suggested again earlier.
Give it a try and see the beauty of automatic control. You cannot do it other way.
Ioannis
I think this video does a pretty good job of showing the potential of this PIC controlled car.
)
With the three sensors this car might be able to negotiate a true maze.
What do you think?
Ken
I wonder if something like this could be made to work for you?
http://www.picbasic.co.uk/forum/showthread.php?t=7393
or
http://www.picbasic.co.uk/forum/cont...gle-Modulation)
Dave
Always wear safety glasses while programming.
Bookmarks