Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

anyone know a PIC BASIC language with "Pulsout" su

Status
Not open for further replies.

lompa

New Member
i know servo control can be done with the pulsout command on a 16f84 (and i have these). is there any software than has support for the pulsout command and can compile for a 16f84 (must be free as i am a student)?

or is there an alternative to "Pulsout"? sticking to basic if i can

These are what i have tried

Proton IDE free version, does but only supports 16f628a
Mikrobasic - no "Pulsout"
PIC basic - no "Pulsout"
MicroCode studio - no "Pulsout"

thanks for your help
 
Just a chance this will help you...let me know :D
**broken link removed**
do a search (edit in I.E) in the above url for the word pulseout
 
Ricardoco said:
Just a chance this will help you...let me know :D
**broken link removed**
do a search (edit in I.E) in the above url for the word pulseout

thanks for that, the code has been taken from there 1 question? is this code using the a PVM function inside the PIC (for the pulsout)? or can this be achieved using any pic eg a 16f84?

DEFINE OSC 4
TRISB = %10000000 'portb is all outputs except portb.7 which has my direction switch

TRISD = %00000000 'set portd as all outputs
minValue con 60 ' set up the min and the max values for my pulseout
maxValue con 240 ' remember if you use a faster clock these have to be changed
'these just are the min and max range of motion for the servo

restperiod con 20 ' the servo needs a rest of about 18 mSeconds
pulseWidth var byte 'this is going to hold the length of pulsewidth that will be pulsed to the servo

pulseWidth = minvalue 'I initialized my starting position at the min

main:

if portb.7 = 1 and pulsewidth < maxvalue THEN 'if I push the switch and
'I haven't gotten to maxvalue yet
pulsewidth = pulsewidth + 1 'I add one to pulsewidth moving it towards max, try other numbers

endif
if portb.7 = 0 and pulsewidth > minvalue then 'if I am not pushing the button and I haven't
'gotten down to minvalue subtract one from pulsewidth
pulsewidth = pulsewidth - 1
endif

low portd.2 'bring pin low so that it can be pulsed high
pulsout portd.2, pulsewidth 'pulse my servo on portd.2 for pulsewidth time
pause restperiod 'pause for 20 mseconds
goto main
 
Most PICs will have a PWM module built in. The PWM is actually a peice of hardware that is designed to output a string of pulses with no help from the CPU - that means that one you get it running you don't need any code to keep it working.

If you look up the PWM module in the Datasheet for your part you can find out what registers you have to load to make the PWM work. This sort of hardware is a bit confusing for a beginner because it doesn't require the CPU. When your program (the CPU) loads the special registers (just like regular memory writes and reads - TRISD = %00000000 is loading a special register that tells the port pins to tristate or not) there is other hardware that is also looking at the same register. The values loaded into the register tell the extra hardware what to do. In the case of the PWM module the registers tell the module how long the pulse should be.
 
bmcculla said:
Most PICs will have a PWM module built in. The PWM is actually a peice of hardware that is designed to output a string of pulses with no help from the CPU - that means that one you get it running you don't need any code to keep it working.

The main problem with the PWM module is that it's limited to one specific pin (or two specific pins if you have two of them). Also, it's pretty useless for generating servo pulses due to their low frequency and very low maximum mark/space ratio.

Pulseout commands in BASIC use software routines, particularly as they are usually intended for various PIC's, many of which won't have PWM hardware.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top