Shop OBEX P1 Docs P2 Docs Learn Events
Count Fonction ...fixed — Parallax Forums

Count Fonction ...fixed

ArchiverArchiver Posts: 46,084
edited 2004-05-13 20:43 in General Discussion
Christian,

I tried the program and found the problem.

The A and B inputs should go into p4 and p5, NOT p6 and p7!

Another reason to put the documentation in the program as you
write it!!

The program works as originally described. Sorry for the confusion.

Tom Sisk



--- In basicstamps@yahoogroups.com, Christian Vermette
<christian_vermette@v...> wrote:
> Thank you Tom
> for your quick response, but I am not able to run the program you
given me,
> I have signal going to pin 6 and 7 (Channel A and B) and signal is
clean I
> already place an Schmitt trigger, led on pin 8 doesn't go on even
the way I
> turn the motor.
>
> Can you give me more in
>
> Regards,
>
> Christian
>
>
Original Message
> From: stamptrol [noparse][[/noparse]mailto:sisk1404@n...]
> Sent: 11 mai, 2004 19:16
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Re: Count Fonction
>
> --- In basicstamps@yahoogroups.com, "vermettechristian"
> <christian_vermette@v...> wrote:
> > Hi every body,
> >
> > Is there a way to get real time count using the Count format,
> Because
> > I need to count pulse from rotary encoder then serial out to
visual
> > basic prog. Some one can be give some tip about.
>
>
> Christian,
>
> Attached is a bit of code to read an encoder. It will
> track which direction the encoder is turning and will run
> up to 50 Hz if you can keep the program short.
>
> ' {$stamp bs2}
>
> ' Program to act as high speed quadrature counter
>
>
> ' Program Name: quadhicount.bs2
> ' Last Update: Mar 10/01 tjs
>
> DIRH=%11111111
>
> counter VAR Word
> counter2 VAR Word
> counter3 VAR Word
> old VAR Nib
> new VAR Nib
> direct VAR Byte
>
> ' Channel a and b of encoder go on inputs 6 and 7 in this case.
> quad:
> counter=127 'load a dummy value so can count up or down
> new = INB & %0011 ' get initial condition
>
> start:
> old = new & %0011 ' remember initial setting
>
> again:
> new = INB & %0011 ' get new reading
> IF new=old THEN again
> direct=new.BIT1 ^ old.BIT0 ' XOR left bit of new with right bit
> of old to get direction
> IF direct=1 THEN cw ' jump here to increment
> LOW 0 ' pin 0 turns led off if turning
counter-
> clockwise
> counter=counter-1 ' jump here to decrement
> OUTH=counter.LOWBYTE
> GOTO start
>
> cw:
> HIGH 0 ' pin 0 turns on led if turning clockwise
> counter=counter+1
> OUTH=counter.LOWBYTE 'turn on leds on pins 8 through 15 to watch
> count
> GOTO start
>
>
>
> Cheers,
>
> Tom Sisk
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject and
> Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.679 / Virus Database: 441 - Release Date: 04-05-07

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-05-13 20:43
    Thank you Tom, now every things go much better, I have a nice project, but
    am a beginner with basicstamp, I alredy built the mecanical parts of table
    with two axis. Control by visual basic prog.

    Christian

    Original Message
    From: stamptrol [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=9cPIni5QetXr9MIwhP0v17P89QPoRER77ZbRqZRpMwGUEHYtkL8B8vCA8Xijxe17eZyKItxBJrQR3Z2F-9U]sisk1404@n...[/url
    Sent: 12 mai, 2004 19:30
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: Count Fonction ...fixed


    Christian,

    I tried the program and found the problem.

    The A and B inputs should go into p4 and p5, NOT p6 and p7!

    Another reason to put the documentation in the program as you
    write it!!

    The program works as originally described. Sorry for the confusion.

    Tom Sisk



    --- In basicstamps@yahoogroups.com, Christian Vermette
    <christian_vermette@v...> wrote:
    > Thank you Tom
    > for your quick response, but I am not able to run the program you
    given me,
    > I have signal going to pin 6 and 7 (Channel A and B) and signal is
    clean I
    > already place an Schmitt trigger, led on pin 8 doesn't go on even
    the way I
    > turn the motor.
    >
    > Can you give me more in
    >
    > Regards,
    >
    > Christian
    >
    >
    Original Message
    > From: stamptrol [noparse][[/noparse]mailto:sisk1404@n...]
    > Sent: 11 mai, 2004 19:16
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: Count Fonction
    >
    > --- In basicstamps@yahoogroups.com, "vermettechristian"
    > <christian_vermette@v...> wrote:
    > > Hi every body,
    > >
    > > Is there a way to get real time count using the Count format,
    > Because
    > > I need to count pulse from rotary encoder then serial out to
    visual
    > > basic prog. Some one can be give some tip about.
    >
    >
    > Christian,
    >
    > Attached is a bit of code to read an encoder. It will
    > track which direction the encoder is turning and will run
    > up to 50 Hz if you can keep the program short.
    >
    > ' {$stamp bs2}
    >
    > ' Program to act as high speed quadrature counter
    >
    >
    > ' Program Name: quadhicount.bs2
    > ' Last Update: Mar 10/01 tjs
    >
    > DIRH=%11111111
    >
    > counter VAR Word
    > counter2 VAR Word
    > counter3 VAR Word
    > old VAR Nib
    > new VAR Nib
    > direct VAR Byte
    >
    > ' Channel a and b of encoder go on inputs 6 and 7 in this case.
    > quad:
    > counter=127 'load a dummy value so can count up or down
    > new = INB & %0011 ' get initial condition
    >
    > start:
    > old = new & %0011 ' remember initial setting
    >
    > again:
    > new = INB & %0011 ' get new reading
    > IF new=old THEN again
    > direct=new.BIT1 ^ old.BIT0 ' XOR left bit of new with right bit
    > of old to get direction
    > IF direct=1 THEN cw ' jump here to increment
    > LOW 0 ' pin 0 turns led off if turning
    counter-
    > clockwise
    > counter=counter-1 ' jump here to decrement
    > OUTH=counter.LOWBYTE
    > GOTO start
    >
    > cw:
    > HIGH 0 ' pin 0 turns on led if turning clockwise
    > counter=counter+1
    > OUTH=counter.LOWBYTE 'turn on leds on pins 8 through 15 to watch
    > count
    > GOTO start
    >
    >
    >
    > Cheers,
    >
    > Tom Sisk
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.679 / Virus Database: 441 - Release Date: 04-05-07



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.

    Yahoo! Groups Links




    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.679 / Virus Database: 441 - Release Date: 04-05-07
Sign In or Register to comment.