Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 24th November 2004, 09:33 PM   (permalink)
Default New to PIC's trying to get a program running have a few Q's

hi thanks for looking in, im looking at a servo controller at the moment that just moves left to right with a 16F84

sorry for being thick but what type of PIC language is this? as it looks very different from the LED programs i have seen

Also do i not need to set header and the equates or do i not need it in this case. Any help of what i would need to add to this program to get it running would be much appreciated. sorry i am very new to this

this is what i have to work with

----Listing 1----

' First servomotor program
' Sweeps left to right, then reverses
Symbol B1 = pw ' create a variable pw
pw = 100 ' start at extreme left
sweep: pulsout 0,pw ' send pulse to motor
pause 18 ' set frequency to about 50 Hz
pw = pw + 1 ' increase pw by 1
if pw > 200 then back ' at extreme right, turn CCW
goto sweep ' otherwise, continue
back: pulsout 0,pw ' send pulse to motor
pause 18 ' set frequency to about 50 Hz
pw = pw - 1 ' decrease pw by 1
if pw < 100 then sweep ' at extreme left, turn CW
goto back ' otherwise, continue

----End of Listing 1----

what lines if any do i need to add?

would MPLAB be suitable?

thanks again

thanks for your time
lompa is offline  
Old 25th November 2004, 03:13 AM   (permalink)
Default

Looks like basic to me.
Unfortunately, I can't add any code cause I program all my pics in C.

As for the mplab, it is only an IDE. It's great for programming and simulating the pic and best of all it's free. Version 7.0 should be out soon

However, another good simulator which I find much more interactive and helpfull is PIC Simulator IDE (www.oshonsoft.com). It's really cheap (~$20 US) and it allows you to see exactly how the ADC or interrupts work. I bought the simulator and I am still amazed at the amount of features and the interactivness of its environment. Although this software loads *.hex files (so you can simulate C, basic or assembler programs), it is primarily oriented towards ppl using basic to program pics.

Anyway, I recommend you check it out unless you want to dive right into programming the hardware.

Hope some of this helps
pop is offline  
Old 25th November 2004, 10:14 AM   (permalink)
Default

thanks for the help does anyone know of eny examples on how to drive a servo with C?

thanks
lompa is offline  
Old 25th November 2004, 07:43 PM   (permalink)
Default

Yup its definitly basic, probably Melabs picbasic.Ithink all that meeds adding is the device type and then would need compileing.Take a look at picbasic.co.uk i think you can d/l a demo version.
martinH is offline  
Old 25th November 2004, 07:58 PM   (permalink)
Default

i didnt realise there was different forms of Basic software, im trying to compile with mikrobasic free demo, but i get errors this is a screen shot of the error

http://server3.uploadit.org/files/contactmat-error1.JPG

would i need to total re design the code for this basic package?

thanks for your help
lompa is offline  
Old 25th November 2004, 09:12 PM   (permalink)
Default

anyone know how to declair "pw" as i am stumped

this is what i have, i have tried "dim pw byte" instead of "Symbol B1 = pw"



program ServoV1

'main procedure
main:

' First servomotor program
' Sweeps left to right, then reverses
Symbol B1 = pw ' create a variable pw
pw = 100 ' start at extreme left
sweep: pulsout 0,pw ' send pulse to motor
pause 18 ' set frequency to about 50 Hz
pw = pw + 1 ' increase pw by 1
if pw > 200 then back ' at extreme right, turn CCW
goto sweep ' otherwise, continue
back: pulsout 0,pw ' send pulse to motor
pause 18 ' set frequency to about 50 Hz
pw = pw - 1 ' decrease pw by 1
if pw < 100 then sweep ' at extreme left, turn CW
goto back ' otherwise, continue

end.
lompa is offline  
Old 25th November 2004, 09:14 PM   (permalink)
Default

Quote:
Originally Posted by lompa
anyone know how to declair "pw" as i am stumped

this is what i have, i have tried "dim pw byte" instead of "Symbol B1 = pw"
How about:

1) Reading the instructions?.

2) Reading the help file?.

3) Looking at the example programs supplied?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 25th November 2004, 09:43 PM   (permalink)
Default

Hi Lompa
ok i d/l mikrobasic and have rewritten the prog .
As i said b4 it uses totally different syntax.
Allso it does NOT seem to have a command for Pulseout
Have a look at picbasic.org and get there proton development demo
its a fantastic peice of software.


heres the above code rewritten as far as mikrobasic can do.

Program MyProject
dim pw as byte
main:
pw = 100
sweep:
'pulsout 0,pw ' send pulse to motor
delay_ms(18) ' set frequency to about 50 Hz
pw = pw + 1 ' increase pw by 1
if pw > 200 then goto back ' at extreme right, turn CCW
end if
goto sweep ' otherwise, continue
back:
'pulsout 0,pw ' send pulse to motor
delay_ms(18) ' set frequency to about 50 Hz
pw = pw - 1 ' decrease pw by 1
if pw < 100 then goto sweep ' at extreme left, turn CW
goto back ' otherwise, continue
end if
end.



all works but no pulseout command
martinH is offline  
Old 25th November 2004, 10:16 PM   (permalink)
Default

Try replacing "dim pw as byte " with "pw var byte"
PicChristmas is offline  
Old 25th November 2004, 10:27 PM   (permalink)
Default

Quote:
Originally Posted by PicChristmas
Try replacing "dim pw as byte " with "pw var byte"

In the mikcrobasic compiler its "dim pw as byte"

In melabs picbasic its "pw var byte"


as i stated they all have different syntax to do the same job
martinH is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 03:56 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker