![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #16 | |
| Quote:
I have a12f675 witch is big brother and it worked on a solderless bread board You have a lot of board to play with and two many jumpers LOL Last edited by be80be; 3rd October 2009 at 09:37 PM. | ||
| |
| | #17 |
|
Hi Burt, Thanks for trying it for me, at least it proves my theory at least was ok. BTW do you think its worth upgrading to MB pro or is it mainly for the larger Pics 18Fs and upwards etc? PS since I had to use a 16F and have spare pins I wondered about incorporating a couple of limit switches so the stepper wouldn't go beyond a set range and wouldn't go the wrong way IE the same way twice as it is for opening and closing a flap, but I think this is beyond me and I can't even get my head round how to do it. Any ideas? Regards..........Al
__________________ Founder member of the Campaign to do Something about the nonexistent word "Somethink" | |
| |
| | #18 |
|
if you draw it out and post we could help you out just the circuit would do. if you have 7.00 or newer mikrbasic keep it it's better then the pro Last edited by be80be; 4th October 2009 at 01:14 AM. | |
| |
| | #19 |
|
I don't no if your setup has mclr pulled up to vdd but if it dos that's why this didn't work I tried some ways to see what came up and that was it. Here the code Code: program steppertest ' Declarations section dim temp as word WPU = %00000000 'turn off weak pullups TRISIO =%00101000 'set GPIO 0,1,2,4 as out and 3,5 as inputs GPIO = %00000000 'turn off all outputs CMCON =0x07 'set comparator to off main: IF GPIO.5 =1 then GOTO up 'check for button press for up END if if GPIO.3 =1 then GOTO down 'check for button press for down END IF GOTO main 'if no presses then restart up: FOR temp = 1 to 5 GPIO = %00010001 'Set on bits for this pulse delay_ms (110) GPIO = %00000011 'Set on bits for this pulse DELAY_MS (110) GPIO = %00000110 'Set on bits for this pulse delay_ms (110) GPIO = %00010100 'Set on bits for this pulse DELAY_MS (110) NEXT temp GOTO main 'After completing pulses return to start down: FOR temp = 1 to 5 GPIO = %00010100 'Set on bits for this pulse delay_ms (110) GPIO = %00000110 'Set on bits for this pulse DELAY_MS (110) GPIO = %00000011 'Set on bits for this pulse delay_ms (110) GPIO = %00010001 'Set on bits for this pulse DELAY_MS (110) NEXT temp GOTO main 'After completing pulses return to start end. Last edited by be80be; 4th October 2009 at 03:42 AM. | |
| |
| | #20 |
|
Hi Burt, Yes thats how I had the circuit, apart from the 1k resistors, I assume the switches on the Easypic5 are just grounded or to pos whichever selected? Can't see any resistors in the paths. I also tried the MCLR pulled high but as you said being on the dev board must have made it error somehow. Anyway I am just going to draw my circuit out with the new 16F and will post it so you can give any ideas on improvement. Thanks mate............Al
__________________ Founder member of the Campaign to do Something about the nonexistent word "Somethink" | |
| |
| | #21 |
|
Hi Burt and all, Here is my circuit along with a rough idea of what I'm trying to do. The flap only needs to open about 30 degrees but must open to the same angle every time hence the stepper. I would have liked a micro switch that could detect when the flap was closed and adjust the stepping cycles to suit automatically or maybe another button or combination of buttons to somehow tell the program where to set open and close points, but this is definately beyond me and my small knowledge of programming. Also I forgot to show the 10k pulldown resistor array on the 2803 inputs in the drawing. Any help or suggestions will be appreciated. Regards............Al PS do I need the delays in the prog to be any particular length for best performance? I have found articles about steppers but they are all too technical for me to grasp. Is there an average time for the pulses? Code: program stepperNOW630 main: DIM t as byte TRISA = %00000000 PORTA = %00000000 TRISC = %00110000 PORTC = %00000000 CMCON =0x07 IF (BUTTON(PORTC,5,1,0))then GOTO up END IF IF (BUTTON(PORTC,4,1,0))then GOTO down END IF GOTO main up: FOR t = 1 to 50 PORTA = %00000001 PORTC = %00000001 delay_ms (10) PORTA = %00000011 PORTC = %00000000 DELAY_MS (10) PORTA = %00000110 PORTC = %00000000 delay_ms (10) PORTA = %00000100 PORTC = %00000001 DELAY_MS (10) NEXT t GOTO main down: FOR t = 1 to 50 PORTA = %00000100 PORTC = %00000001 delay_ms (10) PORTA = %00000110 PORTC = %00000000 DELAY_MS (10) PORTA = %00000011 PORTC = %00000000 delay_ms (10) PORTA = %00000001 PORTC = %00000001 DELAY_MS (10) NEXT t GOTO main end.
__________________ Founder member of the Campaign to do Something about the nonexistent word "Somethink" Last edited by bigal_scorpio; 4th October 2009 at 01:24 PM. Reason: mistake | |
| |
| | #22 | |
|
You want to limited the max right or left rotation be easy to do. Just need to no one thing will it rotate pass 360 to open or close. Quote:
Last edited by be80be; 4th October 2009 at 01:28 PM. | ||
| |
| | #23 | |
| Quote:
The motor does about 5 full revs but the final gear in the train only turns perhaps 30 degrees. The loop I used in the prog is close to what it would need to be, within a few degrees. ![]() And ok I will measure the current drawn and adjust the pulses to suit. Also I will take a picture of the motor setup if it would help? Regards........Al
__________________ Founder member of the Campaign to do Something about the nonexistent word "Somethink" | ||
| |
| | #24 |
|
Hi to all, Anyone who has been following or helped with this thread may be interested to know that I solved the problem I had using the 12F629! It was so blaringly obvious next time I set up the EasyPic5 board for another Pic, I had forgotten that there is a jumper (J7) that sets Masterclear as either reset or I/O and guess what, I had forgot about it and was trying to fight the boards setting.......DOH!!!!!!! Anyway just thought I'd admit my stupidity in case anyone else has a similar issue. Think once think twice think J7 ![]() Al
__________________ Founder member of the Campaign to do Something about the nonexistent word "Somethink" | |
| |
|
| Tags |
| mikrobasic, misbehaving, program |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Whats wrong with my program? MikroBasic | bigal_scorpio | Micro Controllers | 18 | 3rd October 2009 03:35 AM |
| Mikrobasic help.. | mramos1 | Micro Controllers | 11 | 12th November 2008 10:46 AM |
| mikroBasic compiler... | simrantogether | Micro Controllers | 3 | 27th October 2007 10:19 AM |
| mikroBasic and Proton | gramo | Micro Controllers | 0 | 17th March 2007 02:47 PM |