![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| thanks for the help does anyone know of eny examples on how to drive a servo with C? thanks | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
1) Reading the instructions?. 2) Reading the help file?. 3) Looking at the example programs supplied?. | ||
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| Try replacing "dim pw as byte " with "pw var byte" | |
| |
| | (permalink) | |
| Quote:
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 | ||
| |