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.

Help with MikroBasic program misbehaving please

Status
Not open for further replies.
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.
 

Attachments

  • flapcar.JPG
    flapcar.JPG
    67.5 KB · Views: 215
Last edited:
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.

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?
I always set them long and and test motor for proper amp draw as I change the delay shorter.
 
Last edited:
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.


I always set them long and and test motor for proper amp draw as I change the delay shorter.

Hi Burt,

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
 
God I feel so stupid! Solved!

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 :eek:

Al
 
Status
Not open for further replies.

Latest threads

Back
Top