Ken, good luck with your project.
rmteo's comments DO help. I went to WIKIPEDIA and looked up PID and pretty much understand what it is - sort of. It ain't so complicated as the single formulaic representation makes it appear.
Question about PBP and my 16F887. I think the spec for my robocar says to produce one PWM pulse every 20 msec. Each pulse varying in width from 1 to 2 msec in 256 segments. A 1.5msec (created by 127 segments) pulse is neutral. In the case of my Electronic Speed Control anything above 1.5msec is FORWARD. Anything shorter than 1.5msec is BACK. What must I do to scale my chip's 4MHZ oscillator to accomplish this fete?
What I am presently doing I came across by trial and error. I am not sure what shape the PIC is actually producing.
Ken
Lets go back a little
http://www.picbasic.co.uk/forum/show...4621#post94621
Dave
Always wear safety glasses while programming.
I have not learned to SEARCH the forum.
How about I return to basics. How about I make my controls interrupt driven. If had an interrupt routine that ran every 20msec, I could create a true-so-spec PWM signal and I could measure rate of closing speed for each SONAR. I think the 16F887 can get all my work done in 20msec. If not I can up the PIC power.
Way back someone told me how to set up such an interrupt system. Where is that? It's Monday morning. Time to get moving.
Ken
Yes, I looked at Olsson's routines. I got distracted by the thought that my 16F887 is just not up to the task at hand.
I glanced through the MicroChip 18F PICs. My eye fell on the PIC18F46K20.
It comes in 40 pin PDIP format. That is good. It has lots more code memory space. It is on the list of devices that can be programmed by my PICKIT 2 and my Microcode Studio PICBASIC PRO combination. It must be bigger, faster, more capable than my 16F887. True? Which 18F should I choose. I have little to no sense of the differences.
Ken
Ken, What makes you think your current device is not up to the task? R/C systems are very slow IMHO relative to processors. Think on this, pulses for the car happen for 1-2msec each every 20 msec. so 2 pulses (drive & steering) will be max 4 msec. That leaves 16 msec for the uP to do whatever like measure distance and decide what to output next. At 4Mhz clock, thats 16000 ASM instructions! Not PBP instructions but still a whole lot!
So heres a couple of thoughts: Use pulseout for the signals to the car. No need for int or PWM. How about connecting 1 of the car signals from the receiver to your pic. Then just check to see if the pin went high, if so its time to send out commands. This way you can use the car receiver as a 20mSec clock.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
I do not have any experience with the 18F46K20 but two things that I think would make it a good one for this project are:
AndInternal Oscillator Block:
- 8 user selectable frequencies, from 31 kHz to
16 MHz
- Provides a complete range of clock speeds
from 31 kHz to 64 MHz when used with PLL
Enhanced CCP module: In PWM mode, this
module provides 1, 2 or 4 modulated outputs for
controlling half-bridge and full-bridge drivers.
Dave
Always wear safety glasses while programming.
Hey Ken,
I know a lot of people prefer on interrupt type. But my vote for easy interrupt is to use Darrels instant interrupts (and I think an equally large number of people like them as well). Here is a simple example of a blinky interrupt using his include files. The pages on this site have a lot of information about the different kinds of interrupts you can do. Your chip needs to use DT_INTS-14. And of course DT_INTS-18 is for PIC18 devices.
http://darreltaylor.com/DT_INTS-14/blinky.html
Last edited by ScaleRobotics; - 19th November 2010 at 15:20.
http://www.scalerobotics.com
I don't think you want on interupt, just my opinion from reading the manual. I think you want to figure out DT int. Seems to be true int without Dealing with ASM.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
I agree that DT's interrupts or ASM's are the way to go. I gave the ON INTERRUPT code above as an example to get started. Ken will still need to know how pre-scalers and such work no matter what.
Ken seems to want to know the nuts and bolts of things. In my opinion getting a simple code to work with ON INTERRUPTS is a crawl/walk thingy.
I am not real clear on how the motor driver works. I understand it as PWM greater than 127 turns one way and less than 127 turns the other way??
I just drove home trying to simulate Ken's car. Pulsed the same degrees left or right, more pulses left or right for turns but always the same, say 5 degrees off center, and after each pulse returned to center.
What about a two chip solution. The main chip will do nothing more than
center, pulse left, center, pulse right, center...
Second chip deals with the sonar. If a correction needs made a given pin is toggled.
The main chip is using an interrupt on change and completely interrupt driven. The main chip can deal with the pulse left, center, pulse right while the other chip is busy with the next calculation.
Just a half baked thought.
Dave
Always wear safety glasses while programming.
How'd that work out for you?
@Ken, Clearly there is some learning/teaching to be done here. What would you like to start with? DT_INTS or pre scaling and such?
For DT_INTS, I am gonna grab a copy and look/learn it myself. I will prolly jump on the learning side with you when you are ready to go through it. There are plenty here that will be able to answer any/all of our specific questions.
As for the pre scaler, I will go grab a copy of your datasheet. I agree with Dave, this is something you should understand even if you don't need it just yet.
BTW, PIE1 is Peripheral Interupt Enable 1. Without looking (yet) at the datasheet, I am guessing that is the enable for timer 1. In ASM, to use interupts, you must do 2 things. GIE must be set (Global Interupt Enable) this allows any interupt to do its thing. then you must set each interupt enable you want to use such as PIE1. Now with DT_INTS, I think that may be taken care of as part of the include, but I am not sure just yet.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Right now I want an interrupt every 5 millisec. With a 1megahz clock and a 65356 counter, every 5 millisec is every 5000 ticks of that clock. cncmachineguy suggests that I generate an interrupt each time the clock gets down to 60356 by pre-setting the TIMER1 counter.
I understand that, but have not the faintest notion how to accomplish it. I have gone to Darrel Taylor's site. It is well written, but I do not see how it helps me.
Please help me get an interrupt every 5 millisec. Then I can try to figure out what code is needed to control the little car.
Ken
Bookmarks