View Full Version : How do I give a radio control car autonomous control
Kenjones1935
- 9th November 2009, 02:39
I am trying to modify a 1/10 scale RC car to carry a microcontroller with the capability of taking over control of the car. The idea is to hook middle school students into Science, Technology, Engineering, Math by creating a vehicle that can perform both under RC and autonomous control. Controlling the servos and the motors is nothing new. I have found nothing of the interface between the radio control receiver and the microcontroller. Anybody have some suggestions?
ScaleRobotics
- 9th November 2009, 03:37
Here's a simple pulsein example for reading what the receiver is sending the servo's:
http://www.picbasic.co.uk/forum/showthread.php?t=12039
And I used the RCAP pibasic pro based autopilot on an rc plane. I know a few people that have used it to control RC cars. This requires a GOTO gps (like handheld garmin, etc). But for extra credit, the cordic could be used to determine the distance and direction from one waypoint to another ... that is, if gps was in your plan.
Some info, and the picbasic code can be found here:
http://en.wikibooks.org/wiki/RC_Airplane/RCAP
Walter
Melanie
- 9th November 2009, 13:40
Define your vision of 'autonomy'.
When I was a little girl, a favourite uncle of mine gave me a toy electric car for Christmas. It had one switch ON/OFF. Switch it on and the wheels drove forwards in a straight line until it hit an object. On impact, the polarity to the motor was then reversed for a couple of seconds, but because of the central front wheel (it looked like it drove on four, but the two visible front wheels were actually dummy) was housed in a curved slot, when driven backwards the car would swing to the left. The polarity would then switch back and it shot off forwards in a new direction. In this fashion it could travel all round the room - completely autonomous - until the Batteries went flat or you switched it off.
Acetronics2
- 9th November 2009, 14:43
Hi, Mel
Pretty good question ...
let's suppose the model must stay on a 1/10 scale winding road ...
... As it was in the Beatle's song ... a long and winding road.
Precision of a GPS can be enough for a plane ... but a model car ...
Alain
ScaleRobotics
- 9th November 2009, 16:03
You are right, you need a wide road for the RCAP as it is. And no, it is not autonomous, but it includes many of the items that Kenjones1935 is asking about, like an example of a connection to the receiver that allows either transmitter control, or switched to "autopilot" mode, where the pic controls the servo. But I would love to see more examples as well!
Here is 4 or so trecks down a the straight, wide (1/1 scale) roads. Another good place would be a soccer field.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3777&stc=1&d=1257782227
Kenjones1935
- 9th November 2009, 17:34
Thank you all for your encouragement and suggestions.
My vision is a car that can be raced using the regular RC control on a circuit defined in the basketball court of the middle school gym but then the track leads underneath the fold down bleacher seats. The student running the RC can not see under the stands. Remember that under there on the floor are many supporting structures. The car must avoid these on its own.
A different vision is to have the same track on the gym floor, but including a maze made from, say, cardboard boxes that the car must navigate. We could put Xmas tree lights over each of the exit holes in the boxes. In autonomous mode the car could sense the lights.
RC cars have beautiful model suspensions. They go very fast and are quite indestructible. From the point of view of developing STEM thinking they are missing a formal language and repeatable controls. I are trying to marry the two.
Ken
mackrackit
- 9th November 2009, 23:41
Maybe just leave the RC part intact. Add another RC channel and another board.
The second board would be for auto.
The added RC channel would be to switch power from one board to the other.
Kenjones1935
- 10th November 2009, 01:40
Yes, this idea might work.
My problem is that I do not know the details of the I/O signals of the various parts of these 'bots. With LEGO RCX the outputs to the motors come directly from the encapsulated microcontroller system. The motors are not as powerful as those in a RC car. The commands available to the RCX from the ROBOlab program have seven levels of power.
The RC cars, on the other hand, are driven by a 7.2 volt battery pack through a box called a "speed control". Speed control gets its signal directly from the RC receiver. I think it is treated as a servo. Is this pulse width modulation?
I am hoping to borrow an oscilloscope soon.
Ken
mackrackit
- 10th November 2009, 05:29
This might help some.
http://ww1.microchip.com/downloads/en/DeviceDoc/chapter%205.pdf
and the suggestion up in post #2 also.
But yes, PWM is how speed is controlled. How your car is setup I do not know. Maybe if you gave a brand/type someone here might know off hand?
Kenjones1935
- 11th November 2009, 21:16
Still finding it difficult to find the I/O details of my radio control receiver and my electronic motor speed controller. What is on those three wires (white, red and black) between the receiver and the ESC?? Also what is the information format on the three wires (blue, red and black) between the receiver and the servo?
RC receiver: FUTABA FP-R122JE am 2 channel BEC
ESC: NOSRAM Tomahawk Reverse 93050
motor: MABUCHI RS-540RH/SH
John_Mac
- 12th November 2009, 01:01
I have done a lot of work on Autonomous control of RC cars, helis and airplanes. My applications have mostly been on stabilization and waypoints for aircraft using in inertial measurement unit (IMU) board. On the RC car, I ripped out the simple RC controls and replaced them with a Specktrum RX.TX system. I used a PIC processor to convert the throttle PWM signal into something the existing H Bridge motor controller understood and replaced the steering servo with a standard RC servo. I have a camera on a servo controlled pan and tilt servo system, and added things like the Parallax PING sonic distance sensor, and compass module and a GPS (but this only works outside). There are a lot of things you can think of adding.
Looks like you already have a real RX/TX system with a BEC/ESC to a motor. The signal going from the RX to the ESC; Red/Black/Blue(sometimes different color) are +V/GND/Signal. Signal is a Pulse Width Modulated signal whose width tells you how much throttle to apply. Typically this signal will be 3.5v (or so) and a width of 1.2 to 1.8 usec, depending on throttle setting.
Autonomous control will depend on what you want to do and what sensors you need to accomplish it. Waypoints won't work indoors with a GPS, but you can memorize a track, detect obstruction, follow a wire or tape track, lots of things.
A very sophisticated version of indoor automony is a laser scanner that basically maps its environment, but very pricey. You could try a sonar version of this using the PING sensor, lots of math and geometry involved.
Good luck and have a lot of fun with your students.
John
Kenjones1935
- 12th November 2009, 03:39
Thank you, John for answering my questions. I am out here in the middle of Massachusetts. Is there a robotics club around?
My RC car is not the correct one for this job. It has 4 wheel drive and hence a drive belt down the middle where I would mount the PIC. I refer to it because that is all I have. If this idea takes wings a new car can be purchased.
My first thoughts for autonomous control sensors is simple sonic proximity detectors. If they looked to the right and to toward the front, I'll bet I could program the car to follow a wall (close on its right side) until it found an opening (in a corner). Or something....
I need to pick a PIC. I've been told that VEX uses Microchip's 18F8520. Our local technical high school has some VEX kits, but I do not have access to play with them. Any suggestions would be greatly appreciated.
I am a retired digital hardware and software designer. I still have my Texas Instruments 7400 Series TTL catalog. I have not done hardware design since the early 1980's. I am way out of touch.
Ken
John_Mac
- 12th November 2009, 21:43
Thank you, John for answering my questions. I am out here in the middle of Massachusetts. Is there a robotics club around?
My RC car is not the correct one for this job. It has 4 wheel drive and hence a drive belt down the middle where I would mount the PIC. I refer to it because that is all I have. If this idea takes wings a new car can be purchased.
My first thoughts for autonomous control sensors is simple sonic proximity detectors. If they looked to the right and to toward the front, I'll bet I could program the car to follow a wall (close on its right side) until it found an opening (in a corner). Or something....
I need to pick a PIC. I've been told that VEX uses Microchip's 18F8520. Our local technical high school has some VEX kits, but I do not have access to play with them. Any suggestions would be greatly appreciated.
I am a retired digital hardware and software designer. I still have my Texas Instruments 7400 Series TTL catalog. I have not done hardware design since the early 1980's. I am way out of touch.
Ken
Hi Ken
I'm out in Colorado, so don't know much about clubs in Mass, but you do have MIT there and they are well known for their work in robotics. You might see if you could connect with them. The laser scan I mentioned was at MIT. Here is a link you might enjoy:
http://diydrones.com/profiles/blogs/mits-quadcopter-with-laser
I don't really know about VEX, but I have chosen my PICs based on numbers of hardware PWM channels, ADC channels etc...so depends on application. I never found I taxed the speed of the processor.
One thing I started, but never really finished was to put a PING on a servo so I could rotate it left and right. I took a left/right scan and stored the distances to detected obstacles, basically making a map. I could then make decisions on where to go next. You can't really scan very fast though due to a couple of things. The first is that you need to make redundant measurements to filter noise out at each setting, and then the servo is constantly moving and can limit it's lifetime. So this isn't useful for a fast moving car, but maybe a crawler. I like the idea since it requires some math and algorithm development as a learning project.
Kenjones1935
- 13th November 2009, 02:09
John,
Thank you for the pointer to the quadcopter video. It is spectacular.
I am a member of the Cardinal and Gray. The alumni organization for those who graduated from MIT over fifty years ago. I have been looking unsuccessfully for an alumni robotics club.
My impression is that the RC cars world (no microchip) and the VEX school competition world (both RC and autonomous but mostly RC) and the robotics world are completely separate. Then of course there is the land of production machine control.
The RC cars motor can draw up to 80ampere. These cars have a 7.2 volt battery pack that feeds directly to the ESC which in turn gives a dribble of power to the RC receiver. If the micro proto board which has its own battery pack were to provide the PWM signal to the ESC might I not have a power problem?
Really my problem is getting started. I thought the micro controller could be the middle of the car. The RC receiver gives it a low power PWM signal as per usual. When under RC control the micro interprets then passes this signal onto the ESC. If that were the design, the micro could take over control on its own without a command from the human.
I need to pick a microcontroller either a fully packaged one like the VEX, the RCX or the NXT or a proto board. In my past I programmed in machine language and on RISC. More recently it was C, C++ and some higher level languages. That was alll in the work office environment. At home I am starting from scratch. If this looks promising I am pretty sure I can get some help. I need a basic design.
Ken
John_Mac
- 13th November 2009, 02:31
Ken
You probably need to decide if you want the flexibility of a bare PIC or a package that is already programmed. I went with the PIC since I can basically make it do anything I want.
There is a price to be paid to get in that game however. Perhaps you already have all the infrastructure, if not you will need a programmer to write to the PIC, and then decide on the language. Since you are on this forum, you may have PICBasic. If not, you can go assembly (free), C (also free from MicroChip without optimization), or some other language (maybe free, maybe not). There are a lot of programmers out there. MicroChip has some, but other vendors too. I use an ICD2 clone from Sparkfun and PICBasic Pro for smaller PICs and the MicroChip C30 C compiler for dsp chips. I also program in asy, but I can get a lot more done with Basic or C.
If you go the PIC route, I would just use a proto board to build up your circuits.
I typically use an 11v LiPo battery to a BEC to get 5 volts for the board. You can actually take the power off the RX on the Red and Black wires of any channel. This is very low power drain compared to the motor and servos.
Just a suggestion, but I would use an RC car or truck that has a very slow speed option. Fast isn't good when you are trying to debug sensors and code.
One way to switch between manual RC and Auto is to use a channel of the RX that the PIC reads. If it is high, then manual, low then auto for instance. but you need a spare channel. I use a Specktrum DX-7 TX/RX with 7 channels for all the goodies I need to control. This approach is useful if the Auto goes nuts, you can switch to manual with the flick of a switch.
This can get a little expensive to start, but if you plan to stick with it and do similar projects, I think the basic building block approach gives you the most fun....but then again I don;t know what the VEX etc are. And I do a lot of this on many different platforms.
Did I understand you were involving students? It's a great learning project.
John
Kenjones1935
- 13th November 2009, 02:48
The Tech Junkies have this video. They removed the RC control and made the car completely autonomous being guided by the gps satellites.
Their Arduino proto board has a voltage regulator. It produced a 5 volt supply from the 9 volt battery. This would allow me to keep using the 7.2 volt battery pack. I was hoping to keep the speed capability of the RC car.
Ken
Kenjones1935
- 13th November 2009, 23:51
You wrote:
"One way to switch between manual RC and Auto is to use a channel of the RX that the PIC reads. If it is high, then manual, low then auto for instance. but you need a spare channel. I use a Specktrum DX-7 TX/RX with 7 channels for all the goodies I need to control. This approach is useful if the Auto goes nuts, you can switch to manual with the flick of a switch."
Is that as easy as flipping a double pole double throw switch under PIC control?
I have not chosen a PIC. Is the PICaxe Starter Kit for fifty bucks what you would recommend? It does not have any spare proto space. Are pretty much all the sensors I might need directly connectable? Will I need additional off board interface circuitry for, say, a servo or a simple on/off motor? Microchip sells a PIC18FXX20 Demo Board. It contains their 18F8720. I think VEX uses their 18F8520.
I gotta purchase something and get started. One more thing. I have both Windows and Linux PC's at home. I assume that most everybody uses Windows.
Ken
Kenjones1935
- 13th November 2009, 23:56
I don't know how I did not post this URL yesterday
http://ttjcrew.com/
John_Mac
- 14th November 2009, 01:58
Hi Ken
Just looked at the video. Remarkably, this is very similar to what I did and described in my earlier post. Some similarities/differences...I used a larger RC truck platform with 4WD (a junker from Radio Shack), I also ripped all the electronics out and replace the old steering motor with a real servo, I ripped out the RX and motor controller, but kept the H Bridge to be used under PIC control. They put in a new H Bridge, but looks like it was on or off, mine had variable speed control determined by the TX input. They were purely autonomous GPS (only works outdoors). I used a Spektrum DX-7 TX/RX RC system so I could have both RC and Auto control. They used an Arduino board from Sparkfun, I used the MicroChip PIC and my own proto board.
So you see there are many ways to go.
I looked up the VEX system. This is pretty much a lot of plug and play modules that you can buy to do robotics. I think you may still need to buy a TX/RX to have RC control...can get pricey. But you will have to choose.
I am not that acquainted with the various kits that Microchip sells...perhaps others can comment.
I went entirely from the ground up. ICD2 programmer (there are others you can use), I started in assembly but then bought PICBasic Pro (also easy to convert a lot of my old Basic Stamp programs), some 16F88 and 16F627A PIC chips, some proto boards, and supporting electronics (voltage regulator, caps, resistors, jumper wires, header pins,,,,) and built up the hardware and software to make it all work. Most of the sensors from Sparkfun or Parallax will work off a PIC, but you have to read the spec sheets. You will need the usual lab stuff, soldering station, with general electronic parts, batteries, power supplies, and I found the Parallax USB oscilloscope to be absolutely essential in debugging the code. Plus I already had the DX-7 TX/RX. Starting from scratch, this is also pretty pricey way to go. But I had a lot of the stuff and I wanted to be able to modify the control systems at the PIC level for all my projects.
I don't know what you have nor your skill level in this area. You can get some help here on the Forum, but if you go with a plug and play system, it is more turn key and probably forums for those as well. Looks like the Tech Junkie website will have all the code and schematics for what they did, but you would have to go with the Arduino boards which use Atmega chips, not PICs.
Take a look at the DIYDrone website and the ArduPilot system there. this is a great site for autonomous systems, and it is all freeware with most of the parts from Sparkfun. They have lots of stuff you might be able to use and a forum to get a lot of answers....and it is all as cheap as you can get. check this out:
http://diydrones.com/profiles/blogs/ardupilot-main-page
I have a blog there on using a dsPIC IMU system for model helicopters, still PIC based but use C code and microcode C compiler.
You will have to decide the route you take, but it can be a lot of fun.
Good luck
John
Oh...your question on switching from manual to auto...the switch is on the TX. It sends either a short PWM or long PWM to the RX and the PIC reads this to decide if it passes TX signals directly to the servos (manual) or is in control of the truck (auto)....not DTDT switches. And I also use Windows.
Kenjones1935
- 14th November 2009, 15:38
Here's my idea.
The underlying purpose is to interest middle school kids in STEM.
Hobby level RC cars are technically really neat but the engineering is mostly cut and try. Missing is an element of formal language combined with intent. You know formal language as a "blue print" a "recipe" a "musical score" a "program".
I suggest a competition, a race, to be held in the Longsjo Middle School (Fitchburg, Mass) gymnasium plus its lobby. The racing vehicles are 1/10 scale RC hobby level cars or trucks. The race course is delineated on the basketball court by four inch plastic flexible conduit and maybe some traffic cones. The course extends out into the lobby to which there are two doors the width of the basketball court apart.
Inside the lobby is out of sight for the kids handling the RC transmitters. The regular lights are dim in the lobby. A bright light is placed in the doorway that leads back into the gym. The cars must find their own way back into the gym.
Let's guess three or four cars racing each other. The first car to complete three laps wins.
Can I build a car system robust enough to withstand the violence and simple enough to program? I am thinking of a simple language like ROBOlab or Terrapin LOGO. Both of these can easily follow a black line with a light background. I have done that. I think they could also easily find and go to a beam of light.
What do you think? Will it work? Is it practical? Should I start with a PICaxe kit?
Ken
John_Mac
- 14th November 2009, 17:11
Good plan Ken...and glad you are getting students involved.
I cannot comment on the language you quote since I have no experience with them. What you describe, however, sounds very well suited to the Basic Stamp. Look at the Parallax site and look for the Board of Education. This is a Basic Stamp processor with an integrated proto board and voltage supply/regulator. It comes with a Basic Stamp program editor and integrated USB programmer. There are lots of example programs and Parallax sells lots of sensors to interface to it. I actually started my RC truck project on a Basic Stamp. The major limitation was that it has limited program storage for lots of variables. But for simple programs, it is very adequate. they also have more advanced Propeller systems as well. The nice thing about the Basic Stamp is that if you want to go more sofisticated on a PIC, you can get the PICBasic compiler (this site) and the programs port with little changes.
The competition you describe sounds very challenging. Depending on what the obstacles are in the lobby, you may run into some serious navigation issues. An arbitrary course with chairs, tables, cabinets etc would require a great deal of sophistication to navigate. You could put some "clues" in there, such as bright LEDs or something a simple detector can locate and navigate to. If you think of tight turns with an RC car, it requires backing up, turning, etc. hard to do completely autonomously, but not impossible.
I strongly recommend you take a good look at the Basic Stamp. Easy start up, few extra components, relatively cheap (you might get an education discount), simple sensors, and lots of programs out there to build on. It is also an easy step to upgrade to a more complex PIC system from there.
John
Kenjones1935
- 14th November 2009, 20:31
Thank you , again, John,
The Parallax products look just about right. They also seem to offer plenty of support.
Initially I would have no obstacles out in the lobby of the gym. The car would still have to make a 360 turn to find the light at the exit door, then go to it. If I place the light correctly the car would reappear to the RC transmitter person once it reaches the light.
The RC car suspension could be challenged by putting wooden ramps in the gym floor course. The type of tire affects their skidding. Which in turn affects their turning ability at speed.
Thank you again and again for your help.
What do you do professionally? How did you get so involved in RC/auto
flight?
Ken
John_Mac
- 14th November 2009, 21:27
Hi Ken
My pleasure and good luck. Retired physicist here, always played with RC and processors/sensors....just not together. Now that I have time I, get to play with my toys:)
Happy to share ideas and code/schematics, or just another set of eyes.
John
Kenjones1935
- 16th November 2009, 04:02
I am new to Parallax. It comes highly recommended.
I wish to build a 1/10 scale hobby level radio control car that can also run autonomously. I think they have a PIC that can do the job. The question is how do deal with the Pulse Width Modulated signals that come from the radio receiver. Presently they go directly into the electronic speed control module and the steering servo. I thought that for my design I could use them as inputs to the PIC.
I hope that I do not have to use PIC code space and compute power to continuously sample the three RC receive channels. Is there some kind of transition detector which can digitize the PWM signals? I assume the PIC input can figure when they change.
If Parallax does not make an appropriate micro to be the central brains of this operation I can use a DPDT switch under PIC control to steer the PWM signals. There has to be a signal from the radio transmitter telling the car which mode is appropriate. That signal has to be interpreted by the micro somehow.
Ken
John_Mac
- 16th November 2009, 06:23
The Basic Stamp has a function called PULSIN that will give you the width of a pulse on one of the input pins. You can sample multiple pins (input pulses). You can put these 3 PULSIN functions in a loop to keep sampling the PWM inputs. This can be a call in a larger loop that does other things. It shouldn't take much of the CPU power.
The way I do it is to route the RX PWMs into the Basic Stamp then let the code decide if it merely duplicates the pulse in software to the appropriate servo (manual mode) thru an output pic, or let the code take over control (auto mode). No relays or switches to route PWMs, the processor does it all in software.
A note of caution....the Tx/Rx that comes with most (inexpensive) RC cars is not a typical system that you would get if you had a regular RC Tx/Rx system (3 wire standard servo cabling). I ripped all of the truck controls out and replaced with a standard Tx/Rx system (Specktrum DX-7). Not to say you can't make it work, but you better have an oscilloscope and a lot of patience.
The other advantage of a real system is you have more channels to use for more features. One channel can be to tell the car if you want manual or auto for instance.
As I mentioned, I migrated to the PIC from the Basic Stamp to get more power and capability...but still think the Stamp is a good place to start.
John
Kenjones1935
- 16th November 2009, 16:02
John,
I got the following from a Mike Green on the Parallax forum. I think he is agreeing with your decision to migrate up from the Basic Stamp.
With my 1/10 hobby car came a three channel RC unit. One for the DC drive motor, one for the steering servo, and a spare. I thought I could use the spare for the auto/RC toggle. This car is just an experiment to get a working prototype. Once that is done I might be able to find some money for a "real" prototype. There is quite a bit to consider in selecting the race car/truck itself. What do I want to teach about suspensions? I'm not sure.
----------Mike wrote----------
"There is no mechanism for the Stamp to automatically sample the RC channels. Typically you'd use a sequence of 3 PULSIN statements, one for each channel. The RC receiver normally receives one channel at a time and the PWM signals occur in sequence and repeat about 50 times a second. There's not much time left to do control functions once you account for timing 3 RC receive channels and 3 servo PWM output channels. It's possible to offload the PWM output functions, but I don't know any ready-to-go PWM input processor.
"I would strongly suggest you look at the Propeller. It can easily do the RC receiver timing and the servo PWM generation with two cogs (processors) and have plenty of processing power to do whatever control functions you need. The Propeller Servo Controller is a compact board that comes pre-programmed with a 16 channel servo controller, but the outputs can also be used as inputs by modifying the control program."
My next step is to examine the Propeller.
Thanks again..
Ken
John_Mac
- 16th November 2009, 16:33
Mike is correct on the sampling times, however I have made things work well for this application at a much lower rate....basically whenever it gets to it. This can lead to some choppy response on the throttle and steering servo, but nothing bad unless you really load down the processor doing other things.
The Propeller is a better chip, but look carefully at the overall cost of all the cogs and infrastructure compared to a PIC system....might still be cost effective, never used one.
Kenjones1935
- 16th November 2009, 22:10
mackrackit suggested that I use a third RC channel to toggle disconnecting the PIC when under RC control. It does sound like the simplest and maybe the least expensive way to go. Trouble is I do not know how to do this.
Is it as simple as inserting a double pole double throw switch that is controlled by the third channel into the signal line between the RC receiver and the electronic speed control? And another between the receiver and the steering servo?
Will surges and the like kill the electronics? It would be safest if there were a way to guarantee the motor being off and the servo being neutral when toggling. John, mackrackit, what do you think?
Ken
John_Mac
- 16th November 2009, 22:25
Personally I would go with what I described....software control. But someone might come up with an elegant solution. I really don't think you have to keep up with the 25ms servo rate. I have done several applications at lower rates and it works fine. So most processor will work just fine in this mode.
mackrackit
- 16th November 2009, 23:21
John made some good points as to why a hardware solution may not be to your liking.
On the flip side side, a software solution can also have some draw backs. I am coming from an industrial point of view so maybe something non-critical as a RC car could be looked at differently...
To go from manual to auto with software at least one ASM interrupt is needed, depending on the application you may want more from different sources. In your case on should be enough. If the operator can not see the car then switch to auto. Using software the code can be cumbersome. Say you are running in manual. Are you still keeping track of the sensors? That can get to be a neat trick, code space and all. If you do a hardware switch, the auto part can keep monitoring the inputs just as it would if it was in control. This way, when auto does take over it is near seamless.
Good and bad both ways.
If you do go with the hardware solution and the RC part of the car (manual) is still intact then you are halfway there. Find were the inputs to the MOSFET bank are or the motor controller and that is where the DPDT relay will go. Being the control signal is the only thing that is switching the only surge you will have to worry about is from the relay coil. A flyback diode will take care of that.
But either way you go, keep us posted. I have some young ones I am also teaching.
BTW.... I only use windows when I have to...
John_Mac
- 16th November 2009, 23:32
Hi Dave
I agree it depends on the level of glitches you are willing to put up with. I have done what Ken describes with a PIC in a single loop. The call to read PWMs is one element. Sensor analysis is other.
I don't use an interrupt on the lower level PICs. I simply read the mode channel PWM. If it is below some value I jump to manual, if above then to auto. Very simple.
I do much more in the dsPIC which actually interrupts every PWM pulse, but that is way beyond what Ken is talking about. Without interrupts on a mid-range PIC, the throttle will seem a little sluggish in response to changes, this is due to the fact that it is being sampled at less than its normal 25ms rate. But this really isn't a big deal for an RC car. Same is true with steering.
I would think that the sensor calls would only be in auto mode. So no real impact to manual response times. All depends on the details of what Ken ends up doing. I think a simple start is best. There is a big learning curve.
John
mackrackit
- 16th November 2009, 23:42
I think a simple start is best. There is a big learning curve.
Yup, as I was advised a while back when I asked "ASM or PBP first?" the general consensus was to make things as simple as possible so the students would not lose interest.
Keeping the kids excited about something makes MCUs seem easy :)
Kenjones1935
- 17th November 2009, 03:10
Seems that using DPDT relays is the easiest approach to get this car on the road -er gym.
Parallax has been suggested.
If I go with Parallax I need:
BASIC Stamp 2e Module $54.00
either:
BASIC Stamp 2pe Motherboard $70.00
or
Board of Education (USB) - Full Kit $100.00
From TYCO or, 2 AXICOM V23105 dpdt DC relay ~$5.00 each
Maybe some parts from Radio Shack like 7.5 volt power supply and a USB cable.
What else besides my RC car a work bench and some time?
Ken
mackrackit
- 17th November 2009, 03:30
Ken,
Do you have a copy of PicBasic? If so then a PICKIT2 from microchip is less than the cost of a stamp. Micrchip also has a samples option for some of their chips.
The syntax between PB and stamp basic is minimal. But you have many more options with straight PICs. $54.00 for each project :eek:
I bet if you explained what you are doing in a letter on your schools letter head you might get some help from Microchip and Melabs.
Kenjones1935
- 17th November 2009, 14:18
Seems that using DPDT relays is the easiest approach to get this car on the road -er gym.
Parallax has been suggested.
If I go with Parallax I need:
BASIC Stamp 2e Module $54.00
either:
BASIC Stamp 2pe Motherboard $70.00
or
Board of Education (USB) - Full Kit $100.00
From TYCO or, 2 AXICOM V23105 dpdt DC relay ~$5.00 each
Maybe some parts from Radio Shack like 7.5 volt power supply and a USB cable.
I also need a one dimensional light sensor if my BOT is going to find a glowing light bulb on the floor by the exit door.
Parallax has the:
TSL1401 Linescan Imaging Sensor Daughterboard $50.00
What else besides my RC car a work bench and some time?
Ken
Kenjones1935
- 18th November 2009, 03:11
After reading the details of the Parallax
TSL1401 Linescan Imaging Sensor Daughterboard
it seems like overkill. All I want to do is detect that my BOT is pointed at the brightest light in the room. A simple light detector like is used to follow a black line on the floor should be good enough.
Suggestions?
Ken
John_Mac
- 18th November 2009, 03:18
Take a look at the QTI Sensor on the Parallax site...only 6 bucks, emits and receives IR to follow line.
But I'm not sure if you want to follow a line or seek out a bright light??????
John
Kenjones1935
- 18th November 2009, 03:46
John,
I only mentioned the follow-a-line to indicate how simple my needs are. The $50 sensor has great pattern recognizing capability. All I need is something to attach to the front of the car which can tell it that it is going in the right direction. If this device had a lens that would be the best design. If it had a reasonably narrow lens angle then once the BOT found the light, it could stay well directed.
Ken
John_Mac
- 18th November 2009, 04:02
Ah OK got it.
The problem with a simple light detector and lens is that it gives you no positional information as to where to go to seek higher intensity. The linescan sensor you mentioned does due to its pixelated imager...but as you say expensive.
One thing I did similar to this was to mount the detector on a servo that can scan left to right and back. I issued position commands to the servo, then read in the ADC value of the sensor, moved the servo, recorded data, etc. The servo positions were mapped to the forward axis of the truck. A steering correction could then be calculated. Only a few positions are needed to determine if you need to turn to a higher intensity direction, but you need to oversample to filter out noise. Make your steering correction, then start a new scan. You may need a digital filter on the corrections so that you don't oscillate around the proper direction.
You can always buy a smart sensor, but why not make a simple (cheap) one and make it smart with your processor? Also more of a learning experience.
Just a thought.
John
mackrackit
- 18th November 2009, 04:03
Three photo-resistors set 30 to 45 degrees apart (one straight ahead)with a little shielding on each.
John_Mac
- 18th November 2009, 04:08
One thing you will need to do at the start is "global" scan to find the light to start with. It may or may not be in the limited forward acceptance of a detector array. So maybe a 360 azimuth array? or a forward and backward detector on the servo I described?
Kinda depends on the number of input channels are available for this specific function.
John
Kenjones1935
- 18th November 2009, 04:11
John,
My thought was that my light detector would be on the front of my car. The servo searching capability could be done by steering right and left just a little bit. This way the car goes directly to the light.
I imagine that once it gets there, the student operating he RC transmitter will be able to see it and retake control. These things go way fast under RC control. I image it creeps when autonomous.
Make sense to you?
I am having a difficult time figuring out what Basic Stamp starter kit is the best for me. I am USB oriented. I am guessing that I should spring for the 160 bucks for the BASIC Stamp Discovery Kit - Serial (With USB Adapter and Cable)
Your thoughts please. I'm going to bed now. It is eleven o'clock out east.
Ken
Kenjones1935
- 18th November 2009, 04:13
I figured that the very first thing the car would do once under autonomous control would be to make a 360 degree circle. Somewhere in that circle it would be facing the light bulb. That should do it.
Ken
John_Mac
- 18th November 2009, 04:41
Steering to find the source might not converge, but that is part of the fun so try it see what happens.
Dave recommended the PICKIT2 from MicroChip and buy PicBasic compiler. If you know C, you can download a free compiler from MicroChip. I had mentioned the pros and cons of starting with PIC or going to Basic Stamp (ready to go, free compiler, but expensive and one chip/project). Looks like you decided on Basic Stamp.
I would recommend the USB version of whatever you buy. Fewer computers, mostly laptops, have a real serial port.
As I said, I got limited by the number of variables and to some extent the code space on the Basic Stamp. It was a good learning platform, but I eventually went the PIC route, much more flexibility. If you stay in the game and get more complex, you will probably end up migrating to a PIC.
If you go Basic Stamp, USB Board of Education or similar is a good basic system.
You may want Dave to weigh in and see his thoughts.
There is no unique answer.
John
mackrackit
- 18th November 2009, 07:05
I am not up on the basic stamps (SX,propeller), been several years ago that I last played with them. Do they have ADC (Analog Digital Converter) now?
If you go with something like the 18F4550 you have 13 ADCs and it can run at 48Mhz with a 4Mhz external OSC.
Language --- C, ASM, a flavor of Basic??? Of course I am in favor of PBP. It is pretty much bullet proof and the support can not be beat.
How to make an algorithm for automation??? I suppose everyone has their methods but I will study how a human does the task (a large part of my work is automating existing machinery) and go from there. If I find something to make it all more efficient but not something that the humans are doing for whatever reason (360 viewing ?) I will consider a change in the procedure.
It will be interesting to see what the students come up with...
Kenjones1935
- 18th November 2009, 15:48
John and Dave,
I am more than willing to go with PICaxe. We have a MicroChip outlet here in middle Massachusetts close enough for me to enroll in a course or two.
https://secure.microchip.com/RTCV2/ClassesInVenue.aspx?rtcid=5
I am comfortable with C. Many years ago I coded in Assembly. (Funny thing there. I read the Wikipedia definition of PIC. It talked about a Harvard architecture. This description reminded me of the AN/FSQ7 which did the SAGE Air Defense of the USA in the 1950's. That computer was made of vacuum tubes. It read radar data off drums. The PIC Accumulator and Register structures sound similar. That was my first programming job - Lincoln Laboratory)
Please help me select a PIC product kit that would get me started. I need to have that nudge to dig out my soldering iron and borrow an oscilloscope.
Ken
Kenjones1935
- 18th November 2009, 16:25
I have on my computer screen the 101 page PICaxe Manual1.
I don't think I have enough ink to print all 101 pages. I am too old to be comfortable with reading a whole manual on screen. Sigh...
Ken
John_Mac
- 18th November 2009, 21:46
No perfect solution....
PICAxe are MicrChip CPUs that have a bootloader installed so you don't need a programmer to program them. You can't buy any old PIC and make it work, but apparently there are PICAxe chips that look like PIC family. Also don't know their availability, nor cost. The nice thing is that the PICAxe kit comes with the power supply, proto board etc, much like the Basic Stamp which makes prototyping easy. Also looks like it works with MPLAB IDE (free) and the free MicroChip compilers.
To go with the standard PIC route (which is what I do), you will need a programmer like the PICKIT2 on the MicroChip site (not the dev kit, just tthe programmer and USB cable). Then you would need to build up a proto board. Many places sell these in various sizes as well as the jumper cables to hook up your project. You will need to provide a regulated +5 VDC to the board using something like a 7805 regulator and caps. You will need a 5 pin 0.1" header to connect the PICKIT2 programmer to the board to program the PIC. Buy a few PIC's, caps, resistors etc. You download the free MPLAB IDE and C compiler (or buy the PICBASIC compiler to use BASIC. This gets you to a point you can start wiring up a circuit and debug some code.
Unless you start making PCBs, you might keep your project on a proto board with all the components and get another proto board for the next project. Places like Radio Shack and Fry's Electronics sell these boards for a few bucks.
If you go to the MicroChip site, you can get a list of what chips have what capabilities. Might look at 8 bit processors. On of the chips I use is the 16F88. It has 7K of program space, 1 PWM/Capture hardware port, 7 channels of ADC, 3 timers, and 2 comparators. Plenty of capability to get started.
I have already discussed the Basic Stamp system.
So all depends on how much "ready to go" or "DIY" you want. I think people learn a lot more in the end with the DIY approach, but for people that are easily frustrated, not so good.
As you can see, I went the PIC route (although I used a different programmer).
So now you get to decide. Good luck.
John
Kenjones1935
- 19th November 2009, 03:38
John,
You suggested that I use a PICaxe kit that contains a power supply and a proto board etc.
Trouble is I have been trying to figure out which one that is.
Would you be willing to suggest a PICaxe kit model number.
Ken
John_Mac
- 19th November 2009, 04:14
Hmmmm
Don't think I recommended PICAxe...Dave wrote something on it. I just noted that you need special PICs.
Maybe you didn't read my last post.
I'm reluctant to recommend a specific approach, since it depends on what your really want to do. I tried to give the pros and cons of the various systems. For my own personal likes/needs, I went with the PIC route (not PICaxe) described in my last post.
Once you choose which approach you want to take, I can provide specifics.
Best,
John
mackrackit
- 19th November 2009, 04:36
Don't think I recommended PICAxe...Dave wrote something on it. I just noted that you need special PICs.
not me.
I say get a PIC and a PicKit2 and be done with it.
I never have used a picaxe and do not have any plans to.
Get the real thing and pick a language and get started!
John_Mac
- 19th November 2009, 04:38
My mistake Dave///not sure how PICaxe came up come to think of it.
Git er done!
Kenjones1935
- 19th November 2009, 17:37
I did it. I am not sure what I did, but it will get me started. In addition there is a local Radio Shack just a couple miles down the road.
The Microchip Store WEB page said:
DV164121 - PICkit 2 Debug Express
23-Nov-2009 25-Nov-2009 49.99 1
I will need more, but at least I will have something.
Ken
mackrackit
- 19th November 2009, 19:21
Did you order a PIC or two?
Kenjones1935
- 20th November 2009, 01:08
Dave and John,
I think the second item in this description of a Debug Express is a PIC16F887. Isn't that the micro that I need?
Features of PICkit 2 Debug Express:
* PICkit 2 Development Programmer/Debugger
* 44-pin demo board with PIC16F887 Midrange PIC microcontroller
The PIC16F887 may be debugged directly without any additional hardware.
* A series of 12 Lessons on assembly programming that cover I/O, A/D converters, timers, interrupts, and data tables (All source code files are provided)
* A Debugging Tutorial on using the PICkit 2 as a debugger with the MPLAB IDE (Ch. 4 of the PICkit 2 User’s Guide)
* Getting Started in C tutorial on developing and debugging in C with a FREE CCS PCM™ Midrange C Compiler Demo* for PIC16F887(contained on the PICkit 2 CD) *2kWord Program Limit.
* Getting Started in C tutorial on developing and debugging in C with a FREE HI-TECH PICC™ LITE C Compiler with MPLAB IDE
* FREE! Microchip’s MPLAB IDE software for a complete code development environment
----------------Yep. This should get me started--------------
This powerful yet easy-to-program (only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller packs Microchip's powerful PIC® architecture into an 40- or 44-pin package.The PIC16F887 features 256 bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 14 channels of 10-bit Analog-to-Digital (A/D) converter, 1 capture/compare/PWM and 1 Enhanced capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire Serial Peripheral Interface (SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus and an Enhanced Universal Asynchronous Receiver Transmitter (EUSART). All of these features make it ideal for more advanced level A/D applications in automotive, industrial, appliances or consumer applications.
----------------------------------
I am going to need a power supply as I would rather the PIC not share the battery that drives the motor. It is a 7.2v and has plenty of work cut out for it just making the car go fast. Initially I think the PIC gets its power off the USB cord.
I am going to need some relays and some surge eating capacitors.
I am going to need to drive the relay.
I'll need hook up wire and a soldering iron and solder and whatever the modern proto kit uses.
I'll need a light sensor and a way to give it tunnel vision.
What else??
Ken
John_Mac
- 20th November 2009, 01:31
Ken
I'm not sure what the demo board really is that comes with the PICKIT2. If it has to be soldered, you may want to consider getting a proto or bread board to do your prototyping. This is a board with holes into which you can place jumper wires (which you can buy a box of different lengths already cut and bent) and make connections without soldering Typically, I need to mess around with the circuit to make it work or optimize it. Soldering and unsoldering really impacts my ability to try different things and make progress. I save soldering once the circuit has been fully debugged. Also, I would typically put a voltage regulator IC such as the 7805 to provide clean regulated power to the PIC on the proto board. I also use In Circuit Serial Programming (ICSP) using a 6 pin header that the PICKIT2 plugs right into to program the PIC. I don't want to have to pull the chip out every time to program it.
I usually break my project up into logical units and test individually. If you are going to control the throttle with the PIC, you could build a circuit to do this and the PWM code to control it. Same for steering, test out servo control with the kinds of inputs you expect. You may find that the PIC cannot actually drive a steering servo with its own power supply. You may have to provide the control signal from the PIC, but provide a separate power supply for the servo.
Same is true for the light seeking hardware and control software (which will be a bit challenging I think) and your manual/auto relay switching.
Only when all the pieces work, do I attempt to integrate. Even then, one at a time. Thus you can see the benefit of a proto board without soldering (at least for me).
You are also quite right to isolate the power for the motor from the electronic control supply. There are big spikes on it and would be very hard to clean up.
I found an oscilloscope extremely useful in debugging the PWM control circuit and hardware. You can learn a lot about the hardware and software if you can look at the signals.
You may know all this, and can just wire it up, program it and it will all work. If my approach is different than what you want to do, just say so and I will back away from the keyboard:)
Hope this helps
John
Kenjones1935
- 20th November 2009, 02:09
Professionally I did digital hardware design, prototype, build and ship. That ended in 1973. I was working for CODEX. At that time I was promoted to management. I was that long ago? OMG!
I did not like management. I stepped down after a few years (we had a parallel salary scale) and went into programming.
I am now retired. I have forgotten more than I ever learned. I probably would not recognize a modern oscilloscope. Maybe I should go to a flea market to get one made by TI. I haven't seen them yet on Antique Road Show. (A friend of mine in that business mentioned the other day that Heath Kit radios are rising in value.)
I have some design images in my mind for this RC/autonomous vehicle.
The modern acronyms are driving me up he wall. I need to get something in my hands soon!
Ken
Kenjones1935
- 20th November 2009, 03:39
I did not think that Texas Instruments sounded correct when I wrote that last post. They were, of course, Tektronics oscilloscopes that danced to my touch oh those many years ago.
Ken
Kenjones1935
- 20th November 2009, 21:05
I need acronym help.
I need to purchase an appropriate DPDT switch. I plan to use this to switch the BWM signal going into the Electronic Speed Control (the driver of the propelling wheels motor) from either the output of the radio control receiver or the output of the PIC.
Is this the correct set of specs for my proto? I need your judgment on the mounting method. I don't know what the PICkit dictates.
Signal Relay
NEWARK Electronics: Part #35K3233
TYCO ELECTRONICS V23079B1201B301
Coil Voltage VDC Nom:5V;
Coil Resistance:178ohm;
Number of Poles:2;
Contacts:DPDT;
Relay Mounting:PCB Surface Mount;
Carry Current:5A;
Coil Power VDC:140mW;
Leaded Process Compatible:Yes;
I'm headed over to our local Radio Shack. I am not impressed with the RS WEB page.
Ken
John_Mac
- 20th November 2009, 23:31
Ken
You should download the data sheet for your PIC from MicroChip website.
Typically the max current any one pin can drive is 25mA, 100mA total for a port.
So whatever relay you choose must stay below the 25mA level. That is what I told you a while back as a drawback to the relay approach. If you find that you are drawing too much current, you may have to wire up a transistor circuit that drives the current.
The PICKIT2 programmer wont care how you wire things up (other than how it talks to the PIC), but you will need to connect the PICKIT2 programmer to your PIC, through the 6 pin ICSP header I described earlier.
Are you going to use a separate proto or bread board as I mentioned???? Or the demo board that comes with it? I suggest the proto board if the demo board requires soldering (as I said before)
It is very difficult to comment on your questions without a lot more info. You might consider drawing a schematic or something so we are talking off the same page. Also need to know a lot more about what controls you RC truck has on it. Some pictures would help too. Is it a RX with (how many) channels, with standard 3 wire servo cables? Some of the RC trucks have custom electronics to save money.
If you have a standard setup with 3 wire servo cables, you need to switch the signal wire only (this has the PWM signal on it). The power (red typically) and ground (black typically) can be common to all the components. You will need a common ground for all this stuff.
Basically, I just don't have enough info to give you specific guidance at this point...but happy to do so if you provide some info.
Best,
John
Kenjones1935
- 21st November 2009, 02:49
John,
My RC hobby level car has one powerful motor and one servo. The motor drives both the front and the back tires. The servo positions the steering. The RC has three channels. One is not used.
I do not know how to draw a circuit diagram on a computer. What application do you use?
You mentioned a six pin ICSP header. I have no idea what that is. Wikipedia says, "Most PICs that Microchip currently sell feature ICSP (In Circuit ... special headers ". I can not picture that. I am acronym deprived.
I got an email from Microchip today telling me that my order has been shipped. I will wait for it to arrive then go to Radio Shack to see what they sell that looks like what I got. The man there seemed very helpful.
I plan to switch between the two PWM signal aimed at the ESC. Not the power to the motor.
I am concerned about the power because the radio receiver on my car gets its power from the 7.2volt battery via the ESC. I do not want to power the PIC from that source. A common ground is no problem.
You wrote:
"If you have a standard setup with 3 wire servo cables, you need to switch the signal wire only (this has the PWM signal on it). The power (red typically) and ground (black typically) can be common to all the components. You will need a common ground for all this stuff."
I do not want the power to be common to all components. I want the PIC to have its own supply. Yes, it is the white signal line into the ESC that i wish to switch, but that implies common power.
What application do you use to draw a circuit diagram?
Ken
Kenjones1935
- 21st November 2009, 03:01
John,
My calculation for the amperage into the TYCO V23079 DPDT switch is 28mA at 5volts.
The spec says that the coil resistance is 178ohms. Isn't that close enough since this is not counting the output resistance of the PIC port.
Ken
Kenjones1935
- 21st November 2009, 22:55
In order to be able to draw an electronic schematic on this XP based computer downloaded the free version of McCAD Schematics Plus. It comes with a 279 page Adobe Reader Users Guide. I opened the McCAD window. It appears to be totally NOT intuitively obvious. Am I showing my age? Is there a better way?
Ken
Kenjones1935
- 22nd November 2009, 02:54
John,
I want to see if I can send you a .jpg picture of my first scribbles with McCAD. I just uploaded McCADtest.jpg, Does it somehow get attached to this posting? From viewing the Preview apparently the answer is yes.
Ken
John_Mac
- 22nd November 2009, 17:40
Hi Ken
Sorry to have not been very responsive. I had a mother board fail on my server and have been spending my time rebuilding the hardware and software...fun fun fun.
Yes I can read the schematic...
Do you have a digital camera? Sometimes a picture is worth....well you know the saying. I'm still trying to figure out the actual hardware we are dealing with. Don't need hi-res or anything. If you already have the RC Truck, can you tell me the make and model. I could try and look it up.
You might consider ordering some more PICs too, expecially if you are going to be running at or above max limits on the pin current for the relay. It might work fine, but you may not want to be down for a week if it doesn't.
On the ICSP and PICKIT2 programmer....think of this as the interface between your PC and the PIC. The PICKIT2 programmer lets you download the HEX files generated by your compiler, as well as set configuration flags etc. It will write and verify that the code was written correctly. That is a very simplified version, but may help. The ICSP feature is just that you can hook the PICKIT2 programmer to your proto board thru this 6 pin header that it plugs into. It lets you program the PIC in place on the board, rather than pulling the chip and putting it on the demo board. The PICKIT2 probably comes with the 6 wire ICSP cable. It will mate onto 0.1" spaced header pins that you can order online or find at Fry's or equivalent. The header wires go to various locations on the board. Some to the PIC itself. The PIC has programming pins that get activated by the programmer, and also power and ground. I will try to dig up a ref to how to wire it, but MicroChip should have it on their site and the pins will be defined in the Data Sheet (be sure to download this).
Hope this helps.
John
Pic_User
- 22nd November 2009, 18:50
John,
My calculation for the amperage into the TYCO V23079 DPDT switch is 28mA at 5volts.
The spec says that the coil resistance is 178ohms. Isn't that close enough since this is not counting the output resistance of the PIC port.
Ken
Hi Guys,
Great project.
You could hang a transistor on the PIC’s relay driving pin. The transistor will “amplify” the pin’s current. This is the common tried and true way to drive much “heaver” relays. It is a good tool to learn and put into your tool box.
http://www.picbasic.co.uk/forum/showpost.php?p=42017&postcount=6
A quick fix might be to drive the 28 mA relay with two PIC pins in parallel.
Either way, remember to use a suppression diode, directly on the relay coil, to drain any unwanted voltage spikes.
Keep Trucking,
-Adam-
Kenjones1935
- 23rd November 2009, 02:19
Microchip says that my order is 2nd day Fedex. It should arrive either tomorrow (Monday) or Tuesday. Once it arrives I will begin to know where I stand.
Thanks Don for your pointer to the output circuits.
We don't have FRY'S in Massachusetts. We do have YDI (You Do It) but it is a long drive from Fitchburg. Other than Radio Shack what other stores will support me in this project?
My radio control car is not the one for the finished project. It is one I got for the correct price - free. It is a HPI Racing SPRINT 1/10 4WD Electric Touring. It is quite a beautiful little mechanism. It has two differentials. The four wheel drive makes in incovenient for the final vehicle. There is a drive belt the length of the chassis right where the PIC should go.
Electronicly it contains:
One radio receiver, one pretty hefty electronic speed control, one type 540 motor, one steering servo, one 7.2 volt Ni-Cd battery pack.
I had an idea for narrowing the lens angle for my light detector. I could put it at the end of a toilet paper cardboard tube which sticks out the windshield of the vehicle. A reasonably designed 360 degree turn might just allow the 'correct' light sensor to react accurately from, say, thirty to forty feet. What is the correct light sensor assuming I am using a 100 watt incandescent bulb.
Ken
ScaleRobotics
- 23rd November 2009, 02:41
We don't have FRY'S in Massachusetts. We do have YDI (You Do It) but it is a long drive from Fitchburg. Other than Radio Shack what other stores will support me in this project?
There may be more surplus electronics stores around you, but I was able to find one that looks to be an hour away. http://smcelectronics.com/index.shtml
For mail order:
www.digikey.com
www.sparkfun.com
http://www.goldmine-elec.com/
www.halted.com
are nice. I notice that if I can't find it at the surplus stores, it is a LOT cheaper to get mail order than to get them at Radio Shack. Besides Radio Shack does not seem to stock half the parts they used to 5 or ten years ago.
John_Mac
- 23rd November 2009, 02:49
I was able to find:
HPI Racing Sprint 2 Flux RTR w/Ford Mustang GT-R
Must be the same or similar. I looked at the specs and replacement parts and was able to find a picture of the ESC. Indeed it is a standard 3 wire servo cable config. So I assume the RX has the same 3 times 3 pin headers on it to plug the servo cables into it. This is good, cuz most (cheap) models have a custom control system to save cost and is next to impossible to figure out.
You said the RX has 3 channels but only uses 2. That's also good. You can use the 3rd channel for auto/manual detection.
The power to the RX is likely being provided by the servo cable from the ESC. The ground and power pins on the RX are on a bus. You only have to provide one channel to power all. So when you run the servo cable from the unused RX channel to the board, you will have 5 volts (check it) and ground available on the cable to power the board. This power should be fine in terms of conditioning. It is the raw main battery that is dirty.
Here are some sites to look at for parts... there are many more:
http://www.rentron.com/index.html
http://www.sparkfun.com/commerce/categories.php
http://www.parallax.com/
http://www.pololu.com/
Here is an overview of the ICSP I discussed.
http://www.embedinc.com/picprg/icsp.htm
Best,
John
Kenjones1935
- 23rd November 2009, 16:54
I understand that my receiver gets its power from the ESC which in turn is fed by the 7.2volt Ni-Cd battery. Do you all feel that powering the whole kit and caboodle from that one battery is OKAY? If that is the case many of my (imagined) problems are solved. Will the voltage regulator in the ESC withstand the added amperage? If it will then other potential problems disappear.
I still think I need two batteries. One to power the car. The other to power the microchip. The Ni-Cd runs dry after a few high speed runs of the car. It must be recharged. When used as I have been imagining by middle school students it will run down quickly. What happens to all the information in the PIC while I swap batteries?
Ken
I anxiously await the arrival of my PICkit.
Ken
mackrackit
- 23rd November 2009, 17:30
The program memory in the PIC will stay there forever. Any variables will be reset a power up if they are not written to EEPROM. I do not think you will need to worry about that for this project, at least not to start with.
Kenjones1935
- 23rd November 2009, 20:13
You suggested I check out:
http://www.picbasic.co.uk/forum/show...17&postcount=6
I see the reference to latching relays. I found at Newark only 12 volt and greater versions. My mental image of my car/truck carries a 7.2 volt Ni-Cd and a 6 volt AA battery pack. Do you know of an appropriate latching DPDT switch?
Ken
John_Mac
- 23rd November 2009, 21:09
The ESC should work fine for both PIC and steering servo power. I would try it before loading up with separate battery packs. Typically the PIC will reset if you get a glitch on the power. You would see a short dead time while the PIC resets if this happens. You can also flash some LEDs in software on init if you want.
Just look at the ESC output on a scope and see how good/bad it is.
Pic_User
- 23rd November 2009, 23:08
You suggested I check out:
http://www.picbasic.co.uk/forum/show...17&postcount=6
I see the reference to latching relays. I found at Newark only 12 volt and greater versions. My mental image of my car/truck carries a 7.2 volt Ni-Cd and a 6 volt AA battery pack. Do you know of an appropriate latching DPDT switch?
KenHi Ken, John and Dave,
I have seen some 5 V relays but it might be better to power a relay directly from your battery supply.
Then control it with the 5 V signal from the PIC digital pin.
You then, are not limited to the coil current of the PIC pin and more important, the electrical noise from the coil is outside the “inner sanctum” of the sensitive control circuit.
You would need an additional 20 cent transistor driver.
Here in the states these are some of the places that “mail order” electronic supplies.
These are full price electronic part distributors.
They generally have lots of choices and ship very quickly.:
Jameco Electronics http://www.jameco.com/
Mouser Electronics http://www.mouser.com/
Newark Electronics http://www.newark.com/
Digi-Key http://www.digikey.com/DigiHome.html
Allied Electronics http://www.alliedelec.com
These are surplus, few of a kind, less of a selection overstock type places.
Stock quantities are limited and they ship a little slower:
All Electronics Corp http://www.allelectronics.com/
Electronic Goldmine http://www.goldmine-elec.com/
BG Micro Electronics http://www.bgmicro.com/
Marlin P. Jones & Assoc., Inc. http://www.mpja.com/
Fair Radio Sales http://www.fairradio.com/
Hosfelt Electronics, Inc. http://www.hosfelt.com/
I buy most of my parts, to stock the parts bin, from eBay:
eBay Inc. http://www.ebay.com/
You guys are starting an interesting project for all the right reasons!
-Adam aka Pic User-
mackrackit
- 24th November 2009, 00:08
Hey Adam,
Do not be a stranger...
I think Ken could really benifit from your insight on a project like this.
Pic_User
- 24th November 2009, 18:23
Hey Adam,
Do not be a stranger...
I think Ken could really benifit from your insight on a project like this.
You guys are pretty much on top of the whole “Getting Ken up and running with a PIC” mission.
We should caution him and other “newbie PIC users”:
Start slow. Before diving into the atomic powered matter transporter project, blink a LED .
Then make a switch toggle a LED.
Baby step your way, to world dominance.
We are all reading this thread and pulling for Ken to continue with this excellent idea.
-Adam-
Kenjones1935
- 24th November 2009, 20:08
I looks so innocent - so small. It is difficult to imagine it can cause me so much frustration and consternation. Do I need to be careful with static electricity?
Happily I have located a dust covered oscilloscope which should arrive this week. Thanks for the support. It feels good!!!
Ken
mackrackit
- 24th November 2009, 21:19
Static electricity.
If you are not rubbing balloons on your head you are probably OK. :)
I just make sure to touch something that is earth grounded to discharge myself before working. I have NEVER used a wrist strap for any work.
But that is me.
Like Adam said, now it is time for blinkey.
Kenjones1935
- 25th November 2009, 00:39
Gang,
When my PICkit 2 arrived I wondered how I would learn this particular PIC's structure and programming. I do not like reading .pdf files on screen. I hate to use up all my ink printing hundred + page documentation.
Then I noticed ==> sitting open and forgotten on my desk "RUNNING SMALL MOTORS with PIC microcontrolllers" by Harprit Singh Sandhu.
A month ago I purchased this book from AMAZON.com. It was open to Chapter 3 entitled UNDERSTANDING THE MICROCHIP TECHNOLOGY PIC 16F8777A:
That's the PIC in my PICkit! Coincidence?
I'll probably shut up now for a while.... The kids are driving up from New York City. Have a great holiday.
Ken
Ken
Kenjones1935
- 26th November 2009, 22:50
I am having a difficult time with the forest of Microchip .pdf files.
Evidently my PICkit 2 Debug Express does not contain a compiler. I assume it contains an assembler, but I have found neither the specs for assembly language nor the assembler executable itself. Any suggestions?
What higher level language do you all suggest? Which version is the best. How much does it cost?
Ken
mackrackit
- 26th November 2009, 23:46
All the PicKit does is squirt the hex file into the PIC.
If you want to use assembly language you can down load MPLAB from MicrChip for free.
The language we talk about on this forum is Pic Basic or Pic Nasic Pro. One is around a $100 and the other is around $240. I think... With upgrades to new versions for $25, comes with a manual. melabs.com
Kenjones1935
- 26th November 2009, 23:55
I have found something called MPASM which seems to the correct acronym for a microprocessor assembler. We'll see.....
mackrackit
- 27th November 2009, 00:00
MPASM is the assembler. MPLAB is the IDE that it comes with.
Kenjones1935
- 27th November 2009, 02:33
Before we all conversed I purchased two books from amazon.com.
Sandhu's 'Running Small Motors with PIC microcontrollers' has all its code in PIC BASIC PRO. 2000+ lines according to the cover.
Parchizadeh and Vuksanovic's 'PIC Projects - A Practical Approach' has all its code in both assembly and C.
Many (many!) years ago I coded in assembly language a water cooled, vacuum tube constructed architecture eerily similar to the 16F877. We developed shared symbol tables and a library of shared routines. Do these exist in the WEB based world of Microchip PIC?
HI-TECH offers a freeware C - LITE compiler. The price is right, but this forum talks PIC BASIC. Decisions decisions...
Ken
mackrackit
- 27th November 2009, 03:46
Here is the place for ASM and C.
http://www.piclist.com/techref/piclist/index.htm
Start with the "Beginners Checklist" link.
Your project would be fun to have around here but cost is cost.
In ASM for Micros symols are not used.
Here is an example to blink one LED with PBP
DEFINE OSC 20
@ __config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
START:
HIGH PORTD.1
PAUSE 250
LOW PORTD.1
PAUSE 250
GOTO START
Here is an example to blink one LED in ASM.
; processor 16f876a
#include <p16f876a.inc>
ERRORLEVEL -224
; Configuration bits
__CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _WRT_OFF & _DEBUG_OFF & _CP_OFF
CBLOCK 0x20 ; RAM starts at address 20h
d1
d2
ENDC
org 0x0000 ; start address = 0000h
movlw B'00000000'
tris PORTA
movlw B'00000000'
tris PORTB
movlw B'00000000'
tris PORTC
movlw B'00000111'
movwf CMCON
movwf ADCON1
clrf PORTA
clrf PORTB
clrf PORTC
movlw B'00000111'
option
loop:
bsf PORTC,3
call Delay
bcf PORTC,3
call Delay
goto loop
; Delay = 0.1 seconds
; Clock frequency = 4 MHz
; Actual delay = 0.1 seconds = 100000 cycles
; Error = 0 %
Delay ;99993 cycles
movlw 0x1E
movwf d1
movlw 0x4F
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0 ;3 cycles
goto $+1
nop ;4 cycles (including call)
return
end
Kenjones1935
- 27th November 2009, 20:47
I hate .pdf reference manuals. I will stay with the group and purchase PIC BASIC (according to the picture it comes with both a CD and a real 20th Century paper manual). PIC BASIC LITE does not appear in the Microchip SEARCH engine. Oh, well. What's another $250? (I just paid $374 for the left tail light of my car. It comes as one big assembly. All I did was break the red plastic lens!)
I was intimidated by the 270 page and 290 page .pdf files which purported to tell me all I need to know to write in MPASM.
I have coded in assembly, in Pascal, in C and C++ (even fortran way back when). Never in Basic. I hope you guys a patient.
Ken
mackrackit
- 27th November 2009, 21:29
Glad to see you are sticking around.
I have coded in assembly, in Pascal, in C and C++ (even fortran way back when). Never in Basic. I hope you guys a patient.
Melanie is the only one to worry about.
I hear she has a whip :D
Kenjones1935
- 28th November 2009, 04:12
The demo PIC Assembly programs are straight forward. I understood them. They work.
I was happy to discover that the HI-TECH PICC lite integrates into MPLAB IDE easily. It offers a demo program that is much more complicated than the assembly shots. It worked here in sunny scenic Fitchburg Mass.
The MPLAB IDE contains another free C compiler. We'll see what it offers.
Ken
Kenjones1935
- 30th November 2009, 01:57
I ordered five DPDT relay switches early last week from Newark. They have not arrived yet. I have not prototyped a digital/analog circuit is over thirty years. We used wire wrap in the day. Yesterday I bought from Radio Shack solder, a low power iron, some small tools, and three different kinds of proto boards. It is not obvious how we physically attach capacitors, resistors, transistors, to these boards. I gather the inline chips get plugged into sockets that have pins which fit into these proto boards. Their back sides are designed for some kind of wire attachment. Wire wrap?
Can you guys point me to some revealing photographs?
Ken
mackrackit
- 30th November 2009, 09:47
Can you give the Radio Shack part number or picture of what you have?
Byte_Butcher
- 30th November 2009, 16:03
Hi Ken,
When I build prototype projects (that aren't SMD), I usually build them on "perfboard" or "punchboard" or" Vectorboard" or whatever it's called these days.
It's just epoxy glass board with holes punched on a .100" grid.
Stuff the parts in from the top, bend the leads over on the bottom and solder...
Here's a top view of a simple "vectorboard project":
http://www.weirdstuffwemake.com/sweetwatergems/geek/images/board_0676.jpg
And bottom:
http://www.weirdstuffwemake.com/sweetwatergems/geek/images/board_0671.jpg
That's a simple board, but I've done some pretty large and complex circuits using that method and it's worked well for me for over 30 years now.
Put your IC's in sockets so that you can replace them easily if something "bad" happens.
Good luck! And have lots of fun!
steve
Kenjones1935
- 30th November 2009, 17:06
Thank you for the pictures. They gave me some perspective and jogged my memory.
I bought at Radio Shack a Prepunched Perfboard (Steve's picture), a Component PC Board (780 indexed holes) and a Component PC Board (750 solder ringed holes).
The Prepunched Perfboard is what Steve uses. Do the solder ringed holes do the same thing only easier? I gather the indexed holes work well with DIPs.
I am looking at the PICKIT 2. I expected room for four screw sized holes to attach standoffs to hold another board. Does glue work on these boards? I've got a glue gun. I had hoped to prototype the actual RC car with it.
Ken
Kenjones1935
- 1st December 2009, 01:47
I have a freebie copy of the CAD program Schematic Plus. I also have access to CAPTURE.
I have not been able to find Microchip provided vector based images of their products. I would like to add the 44 pin 16F887 to my CAD library.
Ideas?
Ken
Byte_Butcher
- 1st December 2009, 02:18
I would like to add the 44 pin 16F887 to my CAD library.
Ken
44 pin?
I kind of assumed you'd be using a 40 pin DIP package.
I thought all the 44 pin packages were surface mount...
What package style ARE you using?
steve
Kenjones1935
- 1st December 2009, 04:03
Steve,
I had hoped that I could prototype with Microchip's PICkit 2 Debug Express. That may not be practical.
First off FEDEX or whatever has to deliver my PICBASIC PRO software package. Then I need the DPDT switches I'm getting from Newark. Then I need to master the programming. I want to use the DPDT switches to toggle the signals into the rear wheels electronic speed control (ESC) and the steering servo between the radio receiver and the PIC.
I also may need two battery packs. The ESC uses a 7.2 volt Ni-Cd pack. The PIC needs a 5 volt arrangement. I could put a 5 volt regulator in front of the PIC. Trouble is the 7.2 volt batteries do not last very long when at the track. Two voltage sources would be preferable but more difficult to physically install.
I need to be able to draw a schematic. The PIC will control the DPDT switches guided by a binary (PWM?) signal from the third channel in the RC system. The PIC will also have to react to whatever sensor interrupts (light for one and maybe touch in front) as well as generate steering and ESC signals when autonomous.
The RC racing will as original. Its speed and flexibility will not be compromised. Autonomous mobility can be slower. It is still part of the race, but speed will be less important than good programming.
It would be nice to program the autonomous actions with a simple language like LOGO or ROBOlab or whatever is used for VEX. I have not the faintest idea how to accomplish that without direct help from one of those organizations.
Little by little with you guys help==>
Ken
Kenjones1935
- 2nd December 2009, 17:26
My PICBASIC PRO arrived today.
I have gotten more confidence by going down the paths suggested in:
http://letsmakerobots.com/node/928 There are some pictures of prototyping.
I might use a cheap RC car to start. One that has no electronic speed control unit and whose steering is done by a motor, not a servo.
I need hook up wire (Radio Shack).
I have no oscilloscope. All I have is a very old multimeter. Good enough?
Ken
Kenjones1935
- 3rd December 2009, 15:15
Steve,
I am planning to prototype with the PICkit 2 Debug Express. It has a 44 pin surface mounted PIC. I will use hookup wire to jump from the PICkit board to my perfboard. If I blow the PIC a new board costs less than $25.
I am having trouble getting my new PICBASIC PRO software to work. It can compile, but not program. It can not find a programmer application. Maybe I should uninstall the software that came with my PICkit 2 Debugger Express. What do you think?
I am not sure how to proceed. The manual does not give any help.
KEn
mackrackit
- 3rd December 2009, 16:14
Yes, install the PicKit software
Load the HEX into it and and click write. You can turn the power on and off from there also.
There should be a PDF manual with the PicKit or you can get it from Micrchips web site.
Byte_Butcher
- 3rd December 2009, 17:21
Yep, like Dave sez... load up the PICKit software.
The user guide for the PICKit should get you started.
Then it's time to start writing soem simple programs like "Blinky LED" to get a feel for how stuff works.
That 16F887 should be great for your little car. Lots of I/O, 2 HPWM channels, plenty of pins that support ADC to read your sensors.
You mentioned earlier that you have no 'scope, just an old voltmeter. That should be fine for most troubleshooting. You might want to watch Craigslist or Ebay for a used scope. For low speed stuff you can also use a voltage divider on the microphone input of your soundcard, and use a program like Audacity (http://audacity.sourceforge.net/) or similar to capture your waveforms for viewing.
You're gonna have fun. Load up that PICKIT software and get it going! :)
steve
Kenjones1935
- 3rd December 2009, 18:25
Guys,
Last week I had PICkit Assembly code and HI-TECH C code working.
I plucked down $250 for PICBASIC. This is what is not working. It compiles but refuses program. It says that it can not find the programmer. I think its programs are duplicates of what came with the Debug Express package. Some how they are getting confused.
I have a second RC car. It is toy level. Both drive wheels and steering are driven by motors. It is easy to control such a car by PIC. All it needs to do is ON and OFF forward, ON and OFF reverse, ON and OFF steer left, ON and OFF steer right. OFF + OFF makes it steer straight. The steering mechanism has a physical limit mechanism. Controlling the above can be done with four DPDT switches. The car carries 7.5 volts worth of AA batteries.
Back to getting PIC BASIC working..
Thanks,
Ken
mackrackit
- 3rd December 2009, 19:09
If the code is compiling look in your project directory for a HEX file. If one is there then MCS and PBP are working. I would not bother with trying to get MCS to run the PicKit2. Use the PicKit2 software for putting the code in the chip.
Make sure each project has a directory of it's own.
So let us know if you have a HEX file after you hit F9 in MCS.
Byte_Butcher
- 3rd December 2009, 20:13
It is easy to control such a car by PIC. All it needs to do is ON and OFF forward, ON and OFF reverse, ON and OFF steer left, ON and OFF steer right. OFF + OFF makes it steer straight. The steering mechanism has a physical limit mechanism. Controlling the above can be done with four DPDT switches.
Hmmm. Just off the top of my head, I should think you'd only need 2 DPDT relays (1 for forward/reverse, 1 for left/right) and 2 SPST relays, one to turn power on and off to each motor.
Actually, since your 16F887 has 2 HPWM channels, all you need are the 2 DPDT relays for forward/reverse and left/right, and 2 MOSFETS, one on the "low side" of each motor. Now you can use your HPWM channels for ON/OFF control with the added benefit of having SPEED CONTROL on both motors! :cool:
Change your motor speed with a single line of code! :)
Just a thought....
steve
Kenjones1935
- 3rd December 2009, 21:25
I was doing fine with Assembly and HI-TECH C code.
I thought it would be best to go for PICBASIC. I could not find on the Microcode WEB site the $100 PICBASIC product. The only thing available is the $250 PICBASIC PRO package.
It does not work at all!!
The paper manual is useless regarding installation. For example one of the installation windows asks me if I want the compiler in my "environmental path". I have not used DOS since the 1990's. Frankly I forgot what my environmental path is, er was... No comment on this in the Copyright @2009 microEngineering Labs, Inc. manual
I installed everything. It could not find the compiler.
I uninstalled everything Microchip. MPLAB ide V9.30 refused to uninstall per my XP "remove program" feature. I finally deleted the whole C:\Programs Files\microcode directory.
Then, with only the PICBASIC disk in my CD reader I installed PBP again.
All seemed OKAY until I tried the simplest of tests - write, compile and build BLINK.BAS.
I succeeded in moving BLINK.BAS into my workspace. The COMPILE and BUILD said,
"Could not spawn language tool. Check command line options (5)"
What th' ?? The free software has been easier to install and understand and better documented than the $250 package.
Any idea in my computer where there is a file that will explain that compiler comment?
Ken
mackrackit
- 3rd December 2009, 22:23
Can you tell us exactly what does not work? Do not take this the wrong way. Ut it could be a number of things.
For starters you said in another post that the code compiled. Now it does not work at all???
Are you using Micro Code Studio for the code editor?
And who is "Microcode WEB" ? I hope you did not buy from someone that is not authorized.
mackrackit
- 4th December 2009, 00:11
Ken,
I did not mean to sound harsh in the above post.
I will pit together some screen shots tonight to help you get started.
Make sure you have Pic Basic Pro, Micro Code Studio and MPLAB installed in the default directories and we will get you going. They should all be on the Pic Basic CD.
What operating system are you running ?
Kenjones1935
- 4th December 2009, 02:53
First I loaded the MPLAB code that came with PICkit 2 Debug Express. This was version 80. I also loaded Hi-Tech's C lite (free) C compiler.
Every thing worked beautifully. I got an Assembly language bit to work and I got some C working. Both were examples that came with the package.
Then I purchased PICBASIC PRO. Unbeknown to me this CD also had a MPLAB. It is version 83. I did the SETEUP.EXE from the PBP CD. Everything seemed hunky dorry until I tried to do a BASIC program per the manual. No good.
I noticed that now two MPLAB's were installed on my machine. I tried but could not get the WINDOWS XP program remove tool to uninstall MPLAB version 80. Since then nothing has worked correctly.
I have just done a complete new install with everything in their default directories. Let me see what is what.
Ken
mackrackit
- 4th December 2009, 03:14
Ok, I am not home yet but maybe we can go ahead.
Do you have Micro Code Studio installed? If not install it. Leave MPLAB alone and installed for now. You will need a part of it.
Use for now MCS for your code editor.
When you start MCS under the view button on the toolbar there will be compiler options. On the first tab tell it to find PBP if it has not already done so. On the second tab tell it to find MPASM there is a check box. Do not worry about the third tab.
Now when you want to compile hit the F9 key. If no errors are found it will generate a HEX file.
More later.
mackrackit
- 4th December 2009, 11:40
Here are a few screen shots that might help..
This is the first thing you need to do when starting MCS.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3815&stc=1&d=1259925821
Then on the first tab click "Find Automatically". It should find PBP in the root directory. Do not check "Use PBPL", that is only good for 18Fs.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3816&stc=1&d=1259925821
Then on the "Assembler" tab check "Use MPASM" and click "Find Automatically". Check the other radio buttons as shown.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3817&stc=1&d=1259925821
Now you will be able to hit the F9 key to generate the *.hex file. Use the PicKit2 software to program the chip.
Let us know your progress.
Kenjones1935
- 4th December 2009, 15:20
Thank you!!!!
I have successfully done all so far. Is there someplace I could have/should have read this? It certainly is not in the paper manual that comes with PICBASIC PRO.
I gotta go. Will be back later in the day.
Ken
mackrackit
- 4th December 2009, 17:08
I am not sure where this is all documented anymore. The PBP manual deals with the command line for compiling, PBP is a command line program.
Now that you are getting HEXes. Start the PicKit2 software.
After it starts if you do not have it connected to a PIC or you change PICs you will need to check communications.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3819&stc=1&d=1259945759
Then import the HEX.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3820&stc=1&d=1259945759
Click the "Write" button to squirt the HEX to the PIC.
Now to make this automated click the "Auto Import" button. This brings up the open dialog to select a HEX. If you do this, each time you compile by hitting the F9 key in MCS the PICKIT2 software will re-load the HEX and write the PIC. The power can be turned ON/OFF with out changing the settings. Click the "Auto Import" again to go back to normal.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3818&stc=1&d=1259945759
Kenjones1935
- 4th December 2009, 22:03
So far, so good.
Interesting little issues.
ONE, I tried to compile the BLINK.BAS that comes with Microcode Studio. It contained the placer "loop:". The compiler did not like that. It asked for a "do". I edited it to "mainloop". That made the compiler happy. It gave me a .hex file.
TWO: I successfully loaded the .hex into the PIC. After the WRITE command is said Programming Successful. It does not run at all. No blinking of the LEDs. I asked for a verification of the program load. It said, "Verification Successful" I visually checked program memory against the .hex code. It downloaded correctly. Hmmmm...
Guess I gotta learn how to use the debugger.
One more thing. The Microcode Studio compiler accepted 16F877 as the PIC. The PICkit 2 PRogrammer insists it is a 16F887. It gives me no choice. All I can select is Midrange/Standard Configuration.
Here is the BLINK.BAS that It compiled without complaint. I better go check the wiring. Maybe there is no LED atached to PORTB 0
'************************************************* ****************************
'* MICROCODE STUDIO TIPS *
'* *
'* (1) : To get context sensitive help, move your cursor to a PICBasic *
'* : command and then press F1. *
'* (2) : Program assumes the PIC is running at 4MHz. To change the default *
'* : setting (for example, to 20MHz) simply add DEFINE OSC 20 at the *
'* : top of your program. *
'* *
'* This sample program is supplied courtesy of microEngineering Labs Inc *
'************************************************* ****************************
' Example program to blink an LED connected to PORTB.0 about
' once a second
mainloop:
High 0 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Low 0 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds
Goto mainloop ' Go back to loop and blink LED forever
End
Ken
Kenjones1935
- 4th December 2009, 22:08
My magnifying glass tells me that my PIC is a 16F887.
I'll see if that makes any difference to the compiler.
Ken
mackrackit
- 4th December 2009, 22:35
More instructions....
Make sure the jumper is on JP1 on your board.
Go to your PBP directory and find the file 16F887.inc
That is where the PIC is configured. Make it look like below, we will set the fuses in the code. See the lines that are commented with ;
;************************************************* ***************
;* 16F887.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 05/26/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
; device pic16F887, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F887, r = dec, w = -302
INCLUDE "P16F887.INC" ; MPASM Header
; __config _CONFIG1, _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Then compile this
'16F887 BLINK
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
MAINLOOP:
HIGH PORTD.0
PAUSE 500
LOW PORTD.0
PAUSE 500
GOTO MAINLOOP
If you board is the same as the one here...
Kenjones1935
- 4th December 2009, 22:40
The 44 PIN Demo board users guide clearly (in font size ~2 print on Page 35) says that the LED's are attached to PORTD.
I changed the .BAS code per below and the LED blinks!!!
---------------start snip---------------
mainloop:
High PORTD.0 ' Turn on LED connected to PORTD.0
Pause 500 ' Delay for .5 seconds
Low PORTD.0 ' Turn off LED connected to PORTD.0
Pause 500 ' Delay for .5 seconds
Goto mainloop ' Go back to loop and blink LED forever
End
--------end snip----------------
Hurray for our team!!
Ken
Kenjones1935
- 4th December 2009, 22:45
Thank you,
I was looking for that include file, but could not find it.
The printed documentation gave me the details about the board wiring.
Onward and upward to bigger and better things. :rolleyes:
Ken
mackrackit
- 4th December 2009, 22:54
GREAT!!!!!!!!!!!! Glad you got it.
Just for fun here is a "more advanced" blinky.
You might get something out of it. You can add the comments :)
'16F887 BLINK
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
DEFINE OSC 4
TRISD = %00000000
CNT VAR BYTE
MAINLOOP:
FOR CNT = 0 TO 10
HIGH PORTD.0
LOW PORTD.1
PAUSE 500
LOW PORTD.0
HIGH PORTD.1
PAUSE 500
NEXT CNT
FOR CNT = 0 TO 100
PORTD = %01
PAUSE CNT
PORTD = %10
PAUSE CNT
NEXT CNT
GOTO MAINLOOP
Kenjones1935
- 4th December 2009, 22:57
You used many previously defined aliases in the two INCLUDE segments as well as inside our Blink'n code;
'16F887 BLINK
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF
Where are these listed? On what page of which .pdf file?
Ken
mackrackit
- 4th December 2009, 23:01
At or near the end of Microchips *.inc file.
Can be found here
C:\Program Files\Microchip\MPASM Suite
This is the file that has pretty much everything about the chip in it.
Kenjones1935
- 5th December 2009, 03:41
The compiler did not like your @ line.
It felt that three of the aliases were unknown.
I commented out the whole line and the program compiled, programmed and worked exactly as I imagined it would.
I guess I have to investigate the items in the @ line.
Meanwhile I need to pick a light sensor chip for an incandescent light bulb. Got any suggestions? I have to purchase this on line. Our local Radio Shack has no such items.
Ken
mackrackit
- 5th December 2009, 03:50
Did you get an "over writing previous address" error or something like that? If so then I bet the Lines in the PBP *.inc file need commented out. But setting the fuses in thae inc is good too, personal preference kind of thing.
Light sensors. You should get a lot of feed back on that one.
Off the top...
I think you said that the car was going to look for a light. You may want to think about some small solar cells. Being a voltage is produced the ADC could read them directly, well it should if it is not so low a voltage as to not have a good resolution.
Kenjones1935
- 6th December 2009, 02:43
Yes,
It said something like overwriting previous address. It also did not like the comma in the @ line.
Ken
mackrackit
- 6th December 2009, 03:14
Yes,
It said something like overwriting previous address. It also did not like the comma in the @ line.
Ken
There is not a comma in the @ line... typo???
The overwriting previous address is from not have the config lines in the PBP inc file commented.
But if it is working...
Byte_Butcher
- 6th December 2009, 04:10
Ken,
If you just want to detect the direction of a light, I'd just get some generic CDS cells, similar to these:
http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&site=US&WT.z_homepage_link=hp_go_button&KeyWords=pdv-p9001&x=0&y=0
Take 6 or 8 of them and point them in different directions around your car and connect them to the ADC channels on your PIC. Scan the ADC channels to see which one is sucking up the most light...
steve
Kenjones1935
- 6th December 2009, 18:33
I have the bits and pieces. I have the help of this forum.
Now I gotta settle my brain on a design and get to it.
I am imagining the autonomous racer going out into the lobby through one door and returning through the only other door.
Two choices come to my mind.
1. Place a light bulb on the floor at the entrance door. Have the PIC driven car find the light source and follow its beam.
2. Make sure all the doors in the lobby are closed. Have the PIC driven car follow the wall around the room until it finds the second open door.
What do you all think? Got some better ideas?
Thanks
Ken
Byte_Butcher
- 6th December 2009, 19:42
Hi Ken,
I think either the "seek the light" or the "keep the wall on your side" technique would be fine for your purpose.
The "stay close to the wall" method is probably more versatile because it could work in any room with walls...
The "seek the light" method sounds a little cheaper and easier to implement (just a gut feeling). Just point a bunch of CDS cells around the perimeter of the car, read the values into your ADC channels and look for the one with the lowest resistance. If the lowest resistance one ISN'T at the front of the car then you need to correct the steering until is.
With the light method, you'll need to regain control before the car actually GETS to the light, or have a way to make sure it passes to one side so the car doesn't dive straight into the heart of the sun... :eek:
steve
Kenjones1935
- 7th December 2009, 14:58
Decisions have been made. Avoiding the complexity of servo steering and electronic speed control drive wheels seems like a good decision. I am not comfortable with my very dated electronics (read that voltage control, FET's, current surge capacitors) memories.
I will make a fritzl-like wall hugger
(http://letsmakerobots.com/node/928)
that can also be radio controlled. I will use my toy level car much like fritsl's. I have a HiTec Ranger III RC system complete with a HiTec HFS-03MM three channel receiver.
I have Microchip's DM164120-2, a small demo board with a PIC16F887 device on board and a small surface mount prototype area. I am learning how to code it with PICbasic Pro.
All I need to finish are the SRF05 proximity sensors.
Wish me luck. I will keep you posted.
Ken
Kenjones1935
- 8th December 2009, 00:53
The answer is Velcro.
The question is, "How will I attach the PICkit pc board to the plastic chassis of the RC car and the DPDT carrying proto board?"
Ken
Kenjones1935
- 8th December 2009, 03:38
The appeal of the RC cars for hooking middle school students into technology is their near perfect miniaturization of real automobiles.
The toy grade cars just do not have that appeal. They are also too slow.
I understand and can probably duplicate the Pulse Width Modulation waves needed to control the hobby grade motors and servos. The car that I have has three channels. One is unused, it can be the signal controlling the switch from and to autonomous mode.
The idea of using velcro to attach the proto and PICkit boards has eased my mind allot. It is so obvious. Why did I not think of it?
I think, after being certain yesterday, that I have changed my mind. I shall modify my hobby level car for this project.
Ken (sigh....)
Kenjones1935
- 8th December 2009, 20:15
I am now using my hobby level RC car. I am having a Vcc problem. The RC car has a 7.2v battery pack to drive the wheels. These a big batteries, but the wheels use allot of power.
I would like to use four 1 and 1/2v AA batteries to power everything except the drive wheels. That's six volts. The PIC wants 5v. I can not find reverence to voltage regulation inside the PIC. I think I need a voltage regulator - a subject about which I know nothing. Does just inserting a 5v regulator in the Vcc line from the batteries do the job? Which 5v regulator?
Lastly the USB port supplies a pin with 5v on it. Do I just put an ON/OFF switch in the plus 6 volt battery line and turn that source off when using the USB for programming?
Is having three sources of power a blessing or a hindrance ?
Ken
mackrackit
- 8th December 2009, 20:58
If you use 4 AA rechargeable batteries then you will not need a regulator, nominal voltage is 1.2 volts each. But the PIC you are using will run on 2 volts with the 8 Mhz OSC...
So... Use any AA battery pack with a LM317 voltage regulator set to run at ~3.6 volts for the PIC. You will need three 470 ohm resistors to set the regulator. Then you should be able to fire the transistor that is triggering your relay from the PIC.
http://www.national.com/mpf/LM/LM317.html#Overview
The PICKIT2 has an "auto detect" setting for the voltage. if there is voltage on the PIC the PICKIT will deal with it. No switch needed.
Pic_User
- 8th December 2009, 21:34
So... Use any AA battery pack with a LM317 voltage regulator set to run at ~3.6 volts for the PIC. You will need three 470 ohm resistors to set the regulator. Then you should be able to fire the transistor that is triggering your relay from the PIC.
http://www.national.com/mpf/LM/LM317.html#Overview
Like this Dave?
<IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3821&stc=1&d=1260307912 ">
-Adam-
mackrackit
- 8th December 2009, 23:15
Yes, like that.
In practice due to resistors being what they are I have seen 3.3 to 3.7 as you mention. But that has been good enough for me and 3.6 things like SD cards and such.
Kenjones1935
- 9th December 2009, 00:58
I have been looking for a good tool to draw schematics. Which one did you use? Is is freeware? Are the drawings vectors? How did you get it on this page?
Ken
Kenjones1935
- 9th December 2009, 01:12
Dave,
I read that I do not need a voltage regulator to drive my PIC16F887. Then I read which voltage regulator is the best for me.
I am drawing, with a sharpened graphite rod encased in a wooden sleeve, my beginning schematic. I will show it to you all once I figure out how.
Ken
mackrackit
- 9th December 2009, 01:37
Sorry for the confusion. I was just giving some options.
If you want to use a battery pack greater than 5 volts then use the regulator. The reason I like the LM317 is the adjustable aspect and it will handle 1.5 amps.
You may want a regulator while using the ADC on the PIC.
You can upload your drawing with the manage attachments button under the text box. Click quote on Adams post to see how he displayed it.
Pic_User
- 9th December 2009, 02:02
I have been looking for a good tool to draw schematics. Which one did you use? Is is freeware? Are the drawings vectors? How did you get it on this page?
Ken
Hi Ken,
Dave was saying you could use 4 rechargeable (1.2V) cells as is (no Voltage regulator) or regular cells (1.5V) with a LM317 Voltage regulator. You could even use the 7.2v battery pack to power your PIC with the Voltage regulator.
I use Paint.NET. It is not supposed to be a drawing program but it works okay for me.
It is free photo editing software for Windows — http://www.getpaint.net/
It is free and open source. Paint.NET is like Microsoft Paint on steroids.
-Adam-
Kenjones1935
- 9th December 2009, 02:35
Question:
I do not have an oscilloscope. sigh....
Google said that the USB spec rated Vcc at 5 volts. The PICkit 2 printed circuits indicates its Vcc as coming straight from the Microchip PICkit USB interface. It goes directly into the PIC itself. Is there a voltage regulator inside that plastic case? If not the PIC16F887 is seeing 5volts?
On the subject of rechargeable batteries the RC hobby cars gobble through their Ni-Ca drive wheel charges at an awesome rate. I was hoping that the PIC batteries would pretty much last an afternoon. Wouldn't four AA alkaline non-rechargeable batteries be the easiest to deal with? Just put a new bunch in at the start of the day.
Ken
Ken
mackrackit
- 9th December 2009, 03:28
The PicKit does have a voltage regulator built in. The software for it even has a place to set the voltage when using the PicKit2 for a power source.
If you are not using the PicKit2 for a power source the PicKit2 can read the chips voltage and display it.
AA batteries should run all day, but if you power from the motor batteries like Adam suggested then the PIC runs when the car runs. So does it matter? Maybe the motors will make some noise on the circuit? AA batteries would help in that case.
Pic_User
- 9th December 2009, 13:02
The PicKit does have a voltage regulator built in. The software for it even has a place to set the voltage when using the PicKit2 for a power source.
It is handy to just plug in the demo board and run your development project in the early experimental troubleshooting stages, without bothering with a power supply. Then when you need to add the whole circuit you can switch over to the battery pack.
If you do use the PicKit2 for a “power source” in some of the development stages, it is a good idea to run it through a “powered” USB hub.
That way, the powered hub can take the hit when it accidently gets shorted or connected to the wrong polarity. All computers have USB protection circuits but after reading forums for years, there are many people with damaged USB ports.
Don’t ask how I know things get shorted or mis-wired. Just guessing.
-Adam-
Kenjones1935
- 10th December 2009, 02:35
Nuts! is appropriate.
A diversion. The PC into which I had installed MPLAB and PIC BASIC PRO stopped working this afternoon.
There will be a delay in my pursuit of PICkit perfection.
Ken
Kenjones1935
- 14th December 2009, 15:17
Hello everyone.
My machine is back.
I need to know where PIC assembly language is defined. In what document?
I discovered while playing with a blinking program that
LOW PORTD.0
HIGH PORTD.1
and
PORTD = %10
Do not do the same thing. In particular PORTD = %10 clears all the rest of PORTD while the LOW and the HIGH BASIC commands only affects pins 0 and 1. (see below)
Another question. Is there an available document that would provide me with the assembly language interpretation for each PICBASIC PRO command? I found my answer in the .asm code, but I was hoping for an easier all encompassing document.
----snip from COMPLICATED_BLINK.asm--------
#define _PORTD??4 PORTD, 004h
#define _PORTD??5 PORTD, 005h
#define _PORTD??6 PORTD, 006h
#define _PORTD??7 PORTD, 007h
#define _PORTD??0 PORTD, 000h
#define _PORTD??1 PORTD, 001h
INCLUDE "COMPLI~1.MAC"
INCLUDE "PBPPIC14.LIB"
MOVE?CB 0C0h, ADCON0
HIGH?T _PORTD??4
HIGH?T _PORTD??5
HIGH?T _PORTD??6
HIGH?T _PORTD??7
-------end snip------------
My two Devantech Ultrasonic Range Finder SRF05 units just arrived by Fedex.
Soldering iron - here I come.
Ken
Byte_Butcher
- 14th December 2009, 16:26
Hey, good you made it back!
I'm afraid I try and avoid .ASM as much as possible, but if I was looking for the document where PIC ASM is defined.... I'd start with the data sheet for your PIC, in the section titled "Instruction set summary".
steve
Kenjones1935
- 17th December 2009, 14:32
I have printed 300 (ran out of paper) of 384 pages of the PIC16F88x Data Sheet 41291D. On page 231 I found "15.0 INSTRUCTION SET SUMMARY". This document has no Table of Contents.
I need help getting onto hardware prototyping. I am fifty miles from the nearest well stocked electronics components store. What I need is a list of items to purchase when I make the trip. If anyone has a photo I would greatly appreciate it.
I imagine soldering onto my PICKIT 2 connection wires with plugs or sockets. (male or female depending on which wire is 'hot') One or some for A/D converters, PWM input, PWM output, various sensors (sonic range finder and visual spectrum light sensor) and whatever else I might need (suggestions please).
I imagine attaching these various items to my inline proto boards again with wire and matching plugs or sockets.
What off the shelf items would make this 100 mile round trip fruitful.
Ken
Byte_Butcher
- 17th December 2009, 17:43
Hmmm. You have a 16F887, right?
The data sheet I have for it (41291F) is 328 pages and definitely has a table of contents....
It looks like pages 233 - 241 deal with the instruction set.
http://ww1.microchip.com/downloads/en/DeviceDoc/41291F.pdf
But you've got PICBASIC PRO, right? I don't think there's too much need for you to learn ASM unless it's just for educational experience. Why make things harder for a "first project"?
Before you go on a shopping spree, you should figure out what it takes to drive your motors and servos, etc and come up with a schematic or at least a block diagram of some kind.
I assume your car has a DC motor for drive, and a servo for steering position? How much current does the motor draw? You'll probably want one or more logic level MOSFET's to drive it.
I'd get a slab of punchboard to build your circuit on. You'll want a good selection of resistors and caps... If you use CDS cells to "see" light, then you'll want resistors to form voltage dividers with the CDS cells so you can easily measure with an ADC. Of course what values you need depends on many things... including which CDS cells you get. You'll probably want some fairly high value (100K) for gate to source resistors on your MOSFETS. You'll need some caps (maybe some .01 or .1 uF ceramic) for supply bypassing at your PIC and other chips.
Errr... who knows what else you'll need! I think you need more of a game plan, and at least a rough schematic before you drive 50 miles to shop....
steve
Kenjones1935
- 17th December 2009, 18:14
First things first.
I can try to make myself a circuit diagram with a pencil. Better yet I can learn how to use CAPTURE. Then I can share it. I'll give that a shot.
Microchip seems to make many products that interface directly with the 16F887. I have a problem picking out which are appropriate.
Thanks.
Ken
rmteo
- 17th December 2009, 18:14
Or you could use something like this during the learning/development phase (<$150 and should last you a lifetime) EasyPIC6 PIC® development system (http://www.mikroe.com/en/tools/easypic6/):
http://www.mikroe.com/en/tools/easypic6/gallery/easypic6_550_2.jpg
Byte_Butcher
- 17th December 2009, 18:53
First things first.
I can try to make myself a circuit diagram with a pencil. Better yet I can learn how to use CAPTURE. Then I can share it. I'll give that a shot.
Microchip seems to make many products that interface directly with the 16F887. I have a problem picking out which are appropriate.
Thanks.
Ken
I don't think you're gonna need all that much stuff.
You've got the ultrasonic sensors already. A handful of cheap CDS and some resistors takes care of seeing a visible light source.
You'll need to build whatever it takes to drive your motors. Or figure out how to adapt whatever the car has already.
Maybe it would be fun if you posted some pictures of the car you are using, all opened up so we can see what drive motors and control electronics it's got in it already?
Yes, definitely come up with a way to draw and share schematics... even if it's just a pencil and paper and a scanner...
steve
Byte_Butcher
- 17th December 2009, 19:32
Hey Ken,
I dunno if this is any good, but the price is right... Maybe worth a try for drawing schematics?
http://tinycad.sourceforge.net/
steve
rmteo
- 17th December 2009, 19:47
Or do it right the first time around with EagleCad Free Version (http://www.cadsoftusa.com/download.htm)
Byte_Butcher
- 17th December 2009, 20:00
I tried EagleCAD a couple years ago and hated it. I found it to be rather difficult and non-intuitive to use.
I use DipTrace now and I like it a lot. It has a freeware version also
http://www.diptrace.com/
steve
Kenjones1935
- 17th December 2009, 22:12
I have the car. It uses a Tomahawk Reverse Electronic Speed Controller(http://www.nosram.com). I want to use that system directly from the RC receiver for racing. It is proven and its response is sure. It would be nice if I could get the same three wire sockets that this device is accustomed to plug into, but that seems more than I can expect.
I plan to use DPDT switches to toggle between RC receiver control and PIC control. I plan to use the third channel on the RC system to tell the PIC to flip the DPDT switches.
The attached pictures of the car show that it is four wheel drive (there is a drive belt down the middle). This limits my ability to attach the PIC and attendant devices. Once the PIC control works I will be able to get more appropriate 1/10 scale cars or trucks.
I hope the pictures came out OKAY.
Ken
Byte_Butcher
- 17th December 2009, 23:06
Hey Ken, thanks for the photos! I always love to SEE peoples projects.
So the original control circuitry is clearly all sealed up, so it looks you can't hack into it and use any of it's electronics when yer buggy is under PIC control. No problem, I was just curious.
FWIW, here's a simple circuit that uses a MOSFET to drive a motor and a DPDT relay for direction control. You would need one PIC pin to PWM a signal to the MOSFET for speed control, and one pin to drive the relay coil. Of course, depending on how much current your relay draws, you may need another MOSFET or bipolar transistor to drive the relay coil. And a protection diode across the coil always...
Anyway, that would give you speed and direction control on your motor.
http://www.weirdstuffwemake.com/sweetwatergems/electronics/images/simplemotordriver.gif
steve
Byte_Butcher
- 17th December 2009, 23:18
Well, I see it's already too late to edit my original post (sigh), but I didn't want to give the wrong impression when I said I hated EagleCAD..
I'm sure it's a fine program, and I know a LOT of folks use it and love it.
I just found it to be rather... unfamiliar.. compared to other programs I've used, and I found it difficult and non-intuitive (to my brain) to learn.
I stumbled across DipTrace one day and found it to be much more to my liking.
Anyway, I didn't want to sound like I was bashing EagleCAD. I used it long enough to realize it's a good program... I just didn't like the way it felt. It's just a personal preference thing.. like what's yer favorite color. :)
steve
Kenjones1935
- 18th December 2009, 03:19
steve, thank you for your direct control suggestion.
My thought is to hack into the present connection between the RC receiver and the ESC for the drive wheels. I figured with a DPDT switch I could toggle the two wires that are presently connecting the receiver to the ESC (the third wire is ground) between their present state and the PIC. Two wires, one DPDT switch. The red wire is PWM signal. The white one is Vcc. (Actually I think I should leave the white wire floating. Let the ESC use its own power to interpret the PWM signal.) Good idea? No? Insert a diode?
The RC receiver gets its Vcc and gnd from the ESC. My ancient Triplett multimeter tells me that this Vcc is +5v. I know the battery is +7.2v. The ESC must have a 5v regulator on board.
The other DPDT switch is needed to perform much the same operation on the Vcc and signal wires between the receiver and the steering servo motor. In this case the white Vcc wire is driving from the receiver. This one I will switch and drive from the PIC when it is in control.
Thus when the PIC is in control the RC receiver's 5v comes from the
PIC. When the third RC channel signal commands return to RC control the PIC will interpret that and flip the DPDT switches back.
I have this on paper drawn by a #2 pencil. Unreadable by anyone but myself. I'll make you guys a schematic. That may take a couple days. I will be distracted tomorrow and I need to learn about CAPTURE ( I have a bootleg copy. I have to give it a try.)
Ken
Kenjones1935
- 20th December 2009, 23:43
Anybody using CAPTURE for schematics? I am trying, but I have been hit for a loss. I need the library file for the Microchip PIC16F887. I found just that at:
http://f1.grp.yahoofs.com/v1/cKwuS-EkEymWYKbQexI0MM9l9cxeNdG7Nyqyce1tNLWotyc4IkQOBg6t NJE-SUt1bYMzFkBtAlALRK9HzvOabKVxPp_UZ-lRD6yVww/PIC16F88.OLB
Trouble is when I download the file and try to open it with CAPTURE, the error window pops up saying: "Unable to load file 'C:\ORCADWIN\CAPTURE\LIBRARY\PIC16F88.OLB'. Object Not Found."
The file really is there. I can open it with NOTEPAD, but a lot of good that is...
Ken
Kenjones1935
- 29th December 2009, 19:07
I received in the mail yesterday a booklet that mentioned the WowWee product Rovio. They have done what I am planning. They have a BOT which accepts external commends (via WIFI) and also runs autonomously. Interesting.... Not as sexy as my idea (IMHO)
http://www.wowwee.com/en/products/tech/telepresence/rovio/rovio
I'm little by little making a schematic using ORCAD's CAPTURE product.
I am working on my idea not in complete electronic detail. My first picture will include all significant pieces, all connectors, all multi-conductor wires and my best guess as to which piece goes on which prototype board.
This will give me enough of a concept to take to my local RC Cars establishment and to Do It Yourself Electronics. After that the transistors', resistors', capacitors' batteries' and PIC pin selection details will be created.
Thanks for your continued interst.
Ken
mackrackit
- 30th December 2009, 05:43
Looking forward to hearing more and seeing the pictures.
Kenjones1935
- 31st December 2009, 22:07
Attached below is my first try at which parts go where on my radio controlled car. I drew it with a Tee square and triangles. (I could not stick a thumbtack into our oak cutting board? Drawing boards were made of maple - I think)
The parts in the red section are originally in the car.
The blue section is hoped to be on the PICkit 2. (There is an added toggle switch which I may or may not be able to solder to that printed circuit.)
The yellow section is two sonic range control units each on its own fairly small pc card. I need to devise a method to attach them to the car plus an electrical connection method.
The rest, in black, is presumed to fit onto an inline prototype card.
A big issue is the connectors. The more the better if I can make them reliable. I welcome your judgments.
I have not included electronic details. I think I know which PIC pins to use. The three different Vdd sources (USB supplied, 6 volt battery pack and 7.2 volt battery pack) boggle my mind. If I can settle on a physical layout then resisters, capacitors, and transistors will be next.
I need to figure out how to trigger PIC interrupts from the light sensor and the sonic range control.
HAPPY NEW YEAR.
Kenjones1935
- 31st December 2009, 22:33
More details.
Originally the pulse width modulated signals from the radio receiver control the steering servo motor and the amplifier (speed control) which drives the DC motor.
My design has the PIC interrupting that service by controlling the multiple double pole double throw relay switches.
Channel 3 from the radio receiver be used to tell the PIC to toggle between autonomous control and radio control. This decision can be overridden with the toggle switch in the middle of the picture.
Once in autonomous control the car has two means of evaluating its environment. A narrow angle lense (the cardboard tube from a toilet paper roll?) light sensitive device and two sonic range control devices.
The light sensor could find a incandescent light bulb. Once found (by turning in a 360 degree circle for example) a simple line following algorithm should lead the car to the light source.
The front and right side mounted sonic range controls could guide the PIC counter clockwise around the inside of a room. This idea is on the WEB at:
http://letsmakerobots.com/node/928
Thanks all,
Ken
Kenjones1935
- 1st January 2010, 18:56
A quick judgment please.
I just discovered solderless breadboarding. Does it work? Is it reliable? I think I can buy some at You Do It tomorrow. Is it a good idea?
Ken
Pic_User
- 1st January 2010, 19:03
A quick judgment please.
I just discovered solderless breadboarding. Does it work? Is it reliable? I think I can buy some at You Do It tomorrow. Is it a good idea?
Ken
YES! YES, for most prototypes Yes, they are a great way to test ideas.
-Adam-
mackrackit
- 1st January 2010, 20:26
Took a quick look at the schematic and you will need a regulator from the 6 volt battery pack...
As for the bread boards.
Good, bad, and ugly....
That is all I use for proto-typing. Then when I am happy with things I get the soldering iron out.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3851&stc=1&d=1262377417
Kenjones1935
- 2nd January 2010, 02:22
Folks,
OKAY: Details.
My reading of the PICkit 2 Users Guide tells me that AN0 is connected to the on board potentiometer. AN1 is available for my use.
I need to connect the light sensitive resistor to an analog to digital converting input. Please confirm that I am getting this correct.
Pin 20 is A to D input AN1 and available.
It has an input resistance of at least 1Kohm
I can choose my reference voltage to be either Vdd or Vss.
I would install a 1Kohm resistor from Pin 20 to Vdd.
If I were to choose a CDS cell that varies from 1Kohm in darkness to 24Kohm in bright light do you think the A to D on pin 20 could discern the difference?
Yes, a voltage regulator on the six volts. Thank you.
Ken
Kenjones1935
- 2nd January 2010, 02:56
A 5 volt regulator has been suggested. I need to know the power requirement.
I have looked but not found the Microchip spec of the current consumption for the PICkit 2 or for the 16F887 chip itself.
Do you guys know where to look or know the value off hand?
Ken
Kenjones1935
- 3rd January 2010, 03:35
Anybody know what happened?
mackrackit
- 3rd January 2010, 07:47
A 5 volt regulator has been suggested. I need to know the power requirement.
I have looked but not found the Microchip spec of the current consumption for the PICkit 2 or for the 16F887 chip itself.
Do you guys know where to look or know the value off hand?
Ken
I am not sure if there is any one answer. It would depend on the work being done by the chip. ~~How many things and at what current is the PIC driving? LEDs for example.
But saying that..... 1 amp should do for the regulator specs.
Kenjones1935
- 4th January 2010, 00:29
The undisturbed connection between my Fatuba receiver and my ESC box has three wires, black, red, and blue. The black is GND (reference), the red is Vcc (hopefully a regulated 5volts), the third is the signal from the receiver to the ESC telling it which direction and how fast to spin the wheels (what voltage and which polarity to feed the DC motor.)
This is pulse width modulation. How is this information encoded?
My guess is that a square wave (50% Vcc 50% reference) tells the ESC to not power the motor at all. A larger than square wave pulse stream says to feed the motor positive voltage proportional to the area under the pulses. A smaller than square wave pulse indicates to reverse the voltage polarity and feed power inversely proportional to the area under the pulses.
Am I close enough for government work?
Ken
Kenjones1935
- 4th January 2010, 02:47
I bought a Radio Shack 2 1/8 inch IC breadboard socket kit. It looks just like one in your picture.
I am confused on how to use it. I have some dtdp switches that are dual twelve pin packages. They snap into the breadboard just fine, but not over the channel. Hence (if I understand which pins are connected to which correctly) the opposite pins are shorted to each other.
I have a dual inline socket into which the dpdt switch fits fine. It fits bridging the channel of the breadboard. That is what I expected. However, the pins do not snap into place. They are not allowed to become fixed. Could they be too big? I thought everything was standardized.
Our Radio Shack stores are down in inventory and the sales folks know nothing about these pieces.
Ken
mackrackit
- 4th January 2010, 04:28
I do not know anything about the Fatuba, maybe Alan knows...
Unfortunately not everything is standard, most are and the one that are not can be adapted in some way. Might have to make an adapter.
In my picture there are a couple surface mounts, a SD card socket, a 68 pin PLCC, and a part that has the pins at 1 mm.
So I guess I do get the soldering iron out before the project is completely proto-typed.
Kenjones1935
- 6th January 2010, 21:18
I do not see the value of the lower third of the PICkit2 printed circuit board. It looks like I am supposed to use it to breadboard, but there are no holes. Am I supposed to have the skill to solder to the individual PC pads?
I have purchased two different Radio Shack breadboard cards that require soldering. Do I place the components on the side that does not have the PC copper with their legs extending through the holes then solder on the side with the copper? This seems to work fine with the inline dip sockets (as opposed to their uselessness on the solderless board. The problem with that technology is that the legs of the inline dip sockets are not round. They do not snuggle into the springs.)
For drawing a circuit diagram I am using Photoshop. It is not obvious how to draw straight lines with that application, but I have a book....
Ken
Kenjones1935
- 6th January 2010, 21:44
The inline DIP sockets that Radio Shack sells are intended for surface mounting. Their legs are tiny rectangles in cross section (not circles as with wire). If I go to Do It Yourself Electronics they will have DIP sockets intended for solderless breadboarding.
Does that sound correct?
Ken
Byte_Butcher
- 6th January 2010, 21:50
You mean the 44-pin demo board? Yep, it's place to put parts... Plenty of room for 1 or more IC's in SOIC packages, several places to put parts in SOT23 packages, and lots of pads for resistors and caps in 0603 or 0805 packages.
And yes, it's possible to solder them by hand with a good strong magnifying glass, lots of light, and a very fine tipped iron. It's easier with a bit of solder paste and a hot air station with a fine nozzle.
Welcome to the world of surface mount devices. :)
Yes, typically on the breadboard, parts are inserted on the non-coppered side and soldered on the copper side. I always have used plain "unclad" breadboard, and don't have much experience with the copper coated stuff.
Byte_Butcher
- 6th January 2010, 21:53
The inline DIP sockets that Radio Shack sells are intended for surface mounting. Their legs are tiny rectangles in cross section (not circles as with wire). If I go to Do It Yourself Electronics they will have DIP sockets intended for solderless breadboarding.
Does that sound correct?
Ken
Not quite sure what you're asking here. For the solderless breadboard, why would you use a socket? I always used to just stick the IC into the board...
Kenjones1935
- 7th January 2010, 03:26
I have AXICOM P2 20941 DPDT relay switches. They are 12 pin dual in line configuration. The distance between the two rows of pins is .2 inches not enough (.3 inches) to bridge the channel in the solderless board. I need the DIP socket to make the necessary adjustment in width.
I hope to use the solderless boards at least to get started. They are sooo much easier.
A problems is that the hobby level RC components use three wire Z connectors; the radio receiver, female; the Electronic Speed Control, male; the Servo, male. I need to attach these to my circuit board. It is these lines that are switched by the DPTP relay switch.
Ken
Kenjones1935
- 9th January 2010, 03:26
Fellow MicroChip PICers,
I have a PICkit 2. On the board is a PIC16F887. It is printed on the chip. I can read it with a magnifying glass. Also on the board are clearly marked in white ink the signal designations. These marks agree with page 36 of DS41296B 44-PIN DEMO BOARD USER'S GUIDE.
On page 8 of Microchip's DS41291F "PIC16F882/883/884/886/887 Data Sheet is the pin designations for PIC16F884/887.
The printing on the circuit board and the diagram on page 8 do not agree. On the circuit board PIC pins 33 and 34 are not connected. On page 8 these pins are RA6 and RC0 respectively.
On the circuit board these designations are given to PIC pins 31 and 32 respectively. (see attached)
What is UP?? and HELP???
Ken
Kenjones1935
- 9th January 2010, 03:46
To run a Radio Control car from the PIC I need to create two PWM signals. One for the Speed Control that controls the drive wheels and one for the Servo that controls the steering. I see that I am to use CCP1 and CCP2 as outputs.
I also need to interpret a PWM signal (on radio channel 3) which tells the PIC to toggle between radio control and autonomous control. The information on this channel is simple. It is binary, but it is still PWM (I believe).
I am under the impression (mistaken I hope) that the PWM interpreter requires that CCP1 be an input. PLease see "Enhanced Capture/Compare/PWM(CCP1) chapter 11.1, page124 of DS41291D.
Do I have another choice for a pin to connect to channel 3 of the radio receiver?
Ken
Byte_Butcher
- 9th January 2010, 04:29
Fellow MicroChip PICers,
I have a PICkit 2. On the board is a PIC16F887. It is printed on the chip. I can read it with a magnifying glass. Also on the board are clearly marked in white ink the signal designations. These marks agree with page 36 of DS41296B 44-PIN DEMO BOARD USER'S GUIDE.
On page 8 of Microchip's DS41291F "PIC16F882/883/884/886/887 Data Sheet is the pin designations for PIC16F884/887.
The printing on the circuit board and the diagram on page 8 do not agree. On the circuit board PIC pins 33 and 34 are not connected. On page 8 these pins are RA6 and RC0 respectively.
On the circuit board these designations are given to PIC pins 31 and 32 respectively. (see attached)
What is UP?? and HELP???
Ken
Your board has a 16F887 in a TQFP package, not DIP, right?
See page 12 for the TQFP pinout... :)
steve
mackrackit
- 9th January 2010, 07:07
About the PWM.
You might be able to use the PULSIN command and pretty much any pin can be used with that.
I do not know the signal you need to read so this is just a thought.
Kenjones1935
- 9th January 2010, 15:55
I awoke this morning with the thought that those three and four capital letters in the upper left hand corner of the diagram could be significant. I went to page 8 then 9 and 10. That's it. What does TQFP and QFN stand for? At second glance I see one is for a printed circuit and the other is for a socket. Details! Details!
Thank you for the PULSEIN suggestion. I think that is what I need.
I have not prototyped since 1973ish and then I had a technician to physically build the circuits. I am hesitant. First I should get the three power supplies (7.2V battery pack, 6.0V battery pack, 5.0V USB) installed, regulated and grounded. I wish I had an oscilloscope.
(Oh for the good old days of upright analog Tektronix.) You'd think they'd be on the yard sale/antique market.
I shall keep you all in touch.
Thank you for being there.
Ken
Kenjones1935
- 9th January 2010, 16:36
I awoke this morning with the thought that those three and four capital letters in the upper left hand corner of the diagram could be significant. I went to page 8 then 9 and 10. That's it. What does TQFP and QFN stand for? At second glance I see one is for a printed circuit and the other is for a socket. Details! Details!
Thank you for the PULSEIN suggestion. I think that is what I need.
I have not prototyped since 1973ish and then I had a technician to physically build the circuits. I am hesitant. First I should get the three power supplies (7.2V battery pack, 6.0V battery pack, 5.0V USB) installed, regulated and grounded. I wish I had an oscilloscope.
(Oh for the good old days of upright analog Tektronix.) You'd think they'd be on the yard sale/antique market.
I shall keep you all in touch.
Thank you for being there.
Ken
mackrackit
- 9th January 2010, 16:53
Sounds right to me. Get the power supplies working like you want first.
Put maybe a 75% load on the 6 volt to 5 volt regulator just to make sure all is good.
No scope.... A good voltmeter will do. If you spend a little more on a meter you can get one that will read frequency. Kind of does the same thing when checking for a "dirty" power supply.
And capacitors. Use plenty. I bought a bucket of 22uF some time ago so I use them. Place them across VDD and VSS. Even when using batteries the capacitors help a lot. Motors involved. They are a must.
Byte_Butcher
- 9th January 2010, 16:58
I awoke this morning with the thought that those three and four capital letters in the upper left hand corner of the diagram could be significant. I went to page 8 then 9 and 10. That's it. What does TQFP and QFN stand for? At second glance I see one is for a printed circuit and the other is for a socket. Details! Details!
DIP = Dual Inline Package
TQFP = Thin Quad Flat Pack
QFN = Quad Flat No-lead
I wish I had an oscilloscope.
(Oh for the good old days of upright analog Tektronix.) You'd think they'd be on the yard sale/antique market.
Watch Craigslist. Maybe one will show up in your area..
Say, where IS your approximate location? Maybe someone on the list is local to you and has one or knows of one you could get cheap.
You can also put a resistive divider the line in jack on your sound card and use one of the many available O-scope programs for your computer...
steve
mackrackit
- 9th January 2010, 17:13
The other Dave tells about the sound card trick here
http://davehouston.net/learn.htm
Kenjones1935
- 15th January 2010, 01:45
Mucho frustration.
I could not get my DPDT mini-relay switches to work. I unwittingly purchased the "latching" kind with two coils. Neither I nor wikipedia know how these work. Today I ordered the same kind that http://letsmakeroborts.com/node/928 used. 5 to 10 days delivery by land.
I have succeeded in separating the 6volt battery (powers the PICkit, the radio receiver, the steering servo and the proto board) and the 7.2 volt battery (powers the wheels and the electronic speed control). Under radio control the car still runs.
Next step CCP1 and CCP2 pin outputs to the speed control and the servo.
Ken
Byte_Butcher
- 16th January 2010, 01:19
Mucho frustration.
I could not get my DPDT mini-relay switches to work. I unwittingly purchased the "latching" kind with two coils. Neither I nor wikipedia know how these work.
Wikipedia? Hmmm. I imagine the manufacturer has a data sheet available for them. Do they have a part #?
Today I ordered the same kind that http://letsmakeroborts.com/node/928 used. 5 to 10 days delivery by land.
I thought it was 1 if by land, 2 if by sea.
Must be thinking of something else....
steve
Kenjones1935
- 16th January 2010, 03:12
AXICOM, part of TYCO, has a 15 page .pdf file giving the specs to their P2 V23079 Relay product line. No where does it say how, exactly, a latching relay works. It must be common knowledge except hereabouts.
I have never coded in BASIC. I know C and C++ and a few (if I could remember them) older languages. Today I wanted to see what is being INCLUDEd when at the beginning a program I see:
"include 'M16F88x.INC' ; PM header" see below.
Today my question is about PBP INCLUDE files. (see below example) Where are NOLIST and LIST and ifdef and XALL defined? Not, as far as I can find, in the smallish MicroEngineering Labs PICBASIC PRO Compiler booklet. Is there a more complete spec on the WEB? I assume there exists a well constructed public PBP library. Where do I find "intrc_osc_noclkout" (see below code)? When I was working each company I worked for maintained its own C libraries. Is that the way this world works?
;************************************************* ***************
;* 16F887.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2009 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 07/02/09 *
;* Version : 2.60 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
device pic16F887, intrc_osc_noclkout, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F887, r = dec, w = -302
INCLUDE "P16F887.INC" ; MPASM Header
__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Byte_Butcher
- 16th January 2010, 05:09
AXICOM, part of TYCO, has a 15 page .pdf file giving the specs to their P2 V23079 Relay product line. No where does it say how, exactly, a latching relay works. It must be common knowledge except hereabouts.
No, the data sheet isn't very specific about how it works. But it appears from this data sheet, that you energize one coil to "latch" the relay on, and enrgize the other coil to release it. Or you can reverse the polarity on a coil to reverse its effect (e.g., one polarity to latch, and reverse polarity to release.
I think the
http://relays.tycoelectronics.com/datasheets/p2.pdf
At the bottom of pg 4, right hand most of the 3 diagrams, (where it says
"Contacts in reset position. Both coils can be used either as set or reset coils.". I think that bit applies to your relays. You can either energize one coil to "set" the relay and the other coil to "release"..., or you can use one coil and hit it with one polarity to "set", and reverse polarity to release".
steve
Archangel
- 16th January 2010, 05:18
AXICOM, part of TYCO, has a 15 page .pdf file giving the specs to their P2 V23079 Relay product line. No where does it say how, exactly, a latching relay works. It must be common knowledge except hereabouts.
I have never coded in BASIC. I know C and C++ and a few (if I could remember them) older languages. Today I wanted to see what is being INCLUDEd when at the beginning a program I see:
"include 'M16F88x.INC' ; PM header" see below.
Today my question is about PBP INCLUDE files. (see below example) Where are NOLIST and LIST and ifdef and XALL defined? Not, as far as I can find, in the smallish MicroEngineering Labs PICBASIC PRO Compiler booklet. Is there a more complete spec on the WEB? I assume there exists a well constructed public PBP library. Where do I find "intrc_osc_noclkout" (see below code)? When I was working each company I worked for maintained its own C libraries. Is that the way this world works?
;************************************************* ***************
;* 16F887.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2009 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 07/02/09 *
;* Version : 2.60 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
device pic16F887, intrc_osc_noclkout, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F887, r = dec, w = -302
INCLUDE "P16F887.INC" ; MPASM Header
__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Hi Ken,
Those are assembly language instructions, find them in PIC data sheets.
Section 15.
mackrackit
- 16th January 2010, 09:21
Ken,
You will also want to look in the C:\Program Files (x86)\Microchip\MPASM Suite for the *.inc file for your chip. That is where you will find all of the config options, near the end of the file.
To learn a little more about PBP and includes try this.
Start a new project, leave it blank and compile ( you may have to put the configs in you code space if that is the way you are doing it, but nothing more).
Looks at the ASM generated. PBP will do all of the setup from the default includes.
Now add
INCLUDE "modedefs.bas"
to your code. Compile again and look at the ASM file.
Dave
Kenjones1935
- 16th January 2010, 23:16
You all posted in the "PBP projects for R/C models" thread code specifically for the 12F675. My PIC is a 16F887.
I am at a loss to translate from one PIC to the other. My PBP compiler (set up for 16F887) has no idea what to do with GPIO.x references. When I set it for 12F675 it is happy, but the resulting code is useless to my PICkit2.
Is it my job to read about the 12F675 and try to figure out which register in my 16F887 is equivalent? That would be an excellent homework assignment.
Ken
mackrackit
- 17th January 2010, 15:40
Yup, pretty much your job to pull the data sheet and compare pin/port assingments.
Even if you found code for the PIC you are using the pin assingments would probably be different from your setup.
The ADC and other built in hardware things can be confusing from PIC to PIC. So when those kind of things come up we can help you there.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.