couple of questions
Archiver
Posts: 46,084
hi,
I have a coule of questions I hope you can help me with:
I am using a BS2SX in a midi controller. It reads a pot and sends its
value using Serout, but it is sending out a midi message every time
it loops through the program, I want it to send a message only when
the value of the pot has changed. How can I do this?
Would it be possible to use a USB cable to power the Baic Stamp?
Cheers,
Simon
I have a coule of questions I hope you can help me with:
I am using a BS2SX in a midi controller. It reads a pot and sends its
value using Serout, but it is sending out a midi message every time
it loops through the program, I want it to send a message only when
the value of the pot has changed. How can I do this?
Would it be possible to use a USB cable to power the Baic Stamp?
Cheers,
Simon
Comments
You will need an extra variable to remember the last potentiometer
value.
In pseudocode you will get something like this:
"
code to read potentiometer
"
"
IF potentiometer = oldvalue THEN do nothing
ELSE midi_out(potentiometer)
oldvalue = potentiometer
"
and then of course you will have to find a starting value for
oldvalue at the beginning of the program, before the loop starts.
Try to put something like this into your code and let me know the
results.
Regards,
Klaus
--- In basicstamps@yahoogroups.com, "simonrparker"
<simonrparker@y...> wrote:
> hi,
>
> I have a coule of questions I hope you can help me with:
> I am using a BS2SX in a midi controller. It reads a pot and sends
its
> value using Serout, but it is sending out a midi message every time
> it loops through the program, I want it to send a message only when
> the value of the pot has changed. How can I do this?
> Would it be possible to use a USB cable to power the Baic Stamp?
>
> Cheers,
> Simon
different, send a message.
DO
GOSUB Get_Pot
IF (ABS (newPot - oldPot) > Span) THEN GOSUB Send_Midi
oldPot = newPot
LOOP
This code works by comparing the difference between the new and old
values -- that way minor changes due to components won't generate
unnecessary messages. Span is a constant that you will tweak or a valid
movement threshold.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: simonrparker [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Yz8kCSweyGkjmYKikMK_UXvOEE64OYHxaWEzSkLVSLDzgaF2ipxMdhpHZODcItwhWp500A7uizPGEy751dFhUw]simonrparker@y...[/url
Sent: Wednesday, January 28, 2004 4:37 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] couple of questions
hi,
I have a coule of questions I hope you can help me with:
I am using a BS2SX in a midi controller. It reads a pot and sends its
value using Serout, but it is sending out a midi message every time
it loops through the program, I want it to send a message only when
the value of the pot has changed. How can I do this?
Would it be possible to use a USB cable to power the Baic Stamp?
Cheers,
Simon
thanks for your help, what you describe is what I was trying to do
but instead of having "PotStore=Pot" I had "Pot=PotStore", spot the
newbie. Its working fine now, very satisfying, next step is to add
more controls.
Cheers,
Simon
--- In basicstamps@yahoogroups.com, "klausdejong" <klausdejong@x>
wrote:
> Hi Simon,
>
> You will need an extra variable to remember the last potentiometer
> value.
>
> In pseudocode you will get something like this:
>
> "
> code to read potentiometer
> "
>
> "
> IF potentiometer = oldvalue THEN do nothing
> ELSE midi_out(potentiometer)
>
> oldvalue = potentiometer
> "
>
> and then of course you will have to find a starting value for
> oldvalue at the beginning of the program, before the loop starts.
>
> Try to put something like this into your code and let me know the
> results.
>
> Regards,
>
> Klaus
>
>
>
> --- In basicstamps@yahoogroups.com, "simonrparker"
> <simonrparker@y...> wrote:
> > hi,
> >
> > I have a coule of questions I hope you can help me with:
> > I am using a BS2SX in a midi controller. It reads a pot and sends
> its
> > value using Serout, but it is sending out a midi message every
time
> > it loops through the program, I want it to send a message only
when
> > the value of the pot has changed. How can I do this?
> > Would it be possible to use a USB cable to power the Baic Stamp?
> >
> > Cheers,
> > Simon
I've got my initial problem solved now but your solution has raised
some fundamental questions I have like is it possible to use floats
or do we only have integers?
For instance if I debug the maximum value that a potentiometer
gives (Using RCTIME example in Basic Stamp manual)I get 1393, I want
to scale that to 127 so at the moment I am dividing the value of the
pot by 10 then ignoring anything over 127 but this gives quite a bit
of play at the ends of the pot turn.
(using a BS2SX)
Cheers,
Simon
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> Save the old pot value, then compare it to the new pot value -- if
> different, send a message.
>
> DO
> GOSUB Get_Pot
> IF (ABS (newPot - oldPot) > Span) THEN GOSUB Send_Midi
> oldPot = newPot
> LOOP
>
> This code works by comparing the difference between the new and old
> values -- that way minor changes due to components won't generate
> unnecessary messages. Span is a constant that you will tweak or a
valid
> movement threshold.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: simonrparker [noparse][[/noparse]mailto:simonrparker@y...]
> Sent: Wednesday, January 28, 2004 4:37 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] couple of questions
>
>
> hi,
>
> I have a coule of questions I hope you can help me with:
> I am using a BS2SX in a midi controller. It reads a pot and sends
its
> value using Serout, but it is sending out a midi message every time
> it loops through the program, I want it to send a message only when
> the value of the pot has changed. How can I do this?
> Would it be possible to use a USB cable to power the Baic Stamp?
>
> Cheers,
> Simon