Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp and MIDI — Parallax Forums

Basic stamp and MIDI

MaxbMaxb Posts: 16
edited 2005-03-29 17:17 in Learn with BlocklyProp
Hi every body!

for my final school project,
I would like to increase sound volume depending on the distance...

I don't know exactly how to do it, but I have a little idea...I mean 2 ideas
The first one:

1) proximity sensor + basic stamp --midi output + synthetizer + speakers

or

2) proximity sensor + basic stamp -- midi output --cable--USB + PC Pure data (ambient sound coming in)
+ speakers

Is there anybody who has a better idea, or a suggestion..

thanks

Maxb

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-12 22:18
    Idea #1 is pretty easy to implement with the BASIC Stamp.· Have a look at these articles:

    -- http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv94.pdf
    -- http://www.parallax.com/dl/docs/cols/nv/vol4/col/nv95.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-12 23:24
    Wow,

    Nice tutorials,
    I will use it for sure...

    Thanks a lot


    Another thing...
    My last problem was with the ADC,
    (a special 4 channels ADC pin, 8 bytes)

    Now, I am receiving measures,
    but
    instead of giving me a normal (expected)
    value with the proximity sensor (0.42V-2.42V),
    and the force sensor,

    I have some values that are not matching
    with what I calculated

    The results are in HEX...

    e.g. (proximity)
    They are supposed to be between 15 (0.42 Volts) and 7A (2.42V)
    But, I received $01, $02, $0B or $08,
    Which it is strange...
    The lowest value is suppose to be $15,
    (pretty much the same weird thing with the force sensor)


    CODE:

    DEBUG HEX2 ?Proxi
    DEBUG HEX2 ?Force

    Do you have any idea where my problem might be?
    Connections, code, format...

    Thanks again

    Maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-12 23:34
    I have not idea what ADC you're using....

    Are you measuring the inputs to make sure they're what you expect? If yes, then check with the vendor (tech docs) for interfacing rules.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-13 03:54
    Hi,

    Thank you Jon,

    for your help, I appreciate.

    To your question..yes, I am using a special ADC,

    ·made by students of Morgan State University.

    Here is a link for details: http://www.phanderson.com/stamp/a_d.html

    I didn't measure my inputs, but I will...because,·I connected my proximity on 5 V ( Vcc),

    and in the specs, it says that voltage goes from 0 to 2.5V. I will verify it...

    Regards,

    Maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-13 04:16
    Have a look at this ... it might shed some light on that component:

    http://www.rentron.com/four-channel-ad.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-14 17:07
    Good day,

    First,
    I read the document
    http://www.rentron.com/four-channel-ad.htm,
    on a special ADC Morgan Chip, made with a(PIC 12C671 I/P 04 RD8)
    and I decided to put a 1K resistance from serout pin 2(ADC)
    to the microcontroller BS2. works better,

    Then,
    I measured each analog input pin, to see if voltage is correct.
    It was correct (I measured a variation), so I don't understand...
    What I am doing wrong?

    With the Voltmeter, I can see that at 4 inches, the voltage is around 2.42V
    and at 31.5", the voltage is approx. 0.42V, but..

    On my screen, with the debug command:

    SERIN 8, 84, 1000, LED,[noparse][[/noparse]HEX PROXI, HEX SteerL]

    DEBUG HEX2 ?PROXI ' display the result in hexa
    DEBUG HEX2 ?SteerL

    Results
    Proximity sensor at 4 inches (2.42V)
    and Force sensor(SteerL) (4.9V without any force)

    2005-03-14 11:59:53 -0500
    PROXI = $0F
    SteerL = $0F
    PROXI = $07
    SteerL = $09
    PROXI = $08
    SteerL = $08


    Results
    Proximity sensor at 8 inches (1.45V)
    and Force sensor (5V without any force)

    2005-03-14 12:00:32 -0500
    PROXI = $04
    SteerL = $04
    PROXI = $04
    SteerL = $0F
    PROXI = $04
    SteerL = $0C
    PROXI = $0F
    SteerL = $06

    I calculated that at 4", it sould be $7A,
    and at 8", it sould be $43

    I am confused..
    and don't know what to do

    A little help would be appreciated...

    thanks

    maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-14 19:16
    Let me suggest you get a handle on your "special" A2D before trying to put it into your program. You should probably just connect a pot (or 4) so that you can measure fixed input values and then check the output stream. If your voltage inputs are moving around it may be tough to examine the output and make sense of it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-14 19:18
    Another thing ... using "magic number" constants for the SERIN baudrate parameter nearly always gets people in trouble. Using our standard programming template will allow you to set the baud rate quickly without hassle, and change it from true to inverted easily as well. The baud setting (mode, not speed) may be incorrect for the part.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-14 23:10
    Thanks again,
    for all the info...

    but,
    I made some tests with ADC 0831, and it worked well. (reliable)
    so, I guess , I'll buy a ADC 0834.

    maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-14 23:50
    I don't have an ADC0834, but I have used the ADC0832 and adapted my program -- this should get you started.· As with the other, test your inputs with fixed values first just to make sure you're getting good values from your pots; then incorporate the data into your MIDI application.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-15 23:49
    Wow..

    Thank you Jon,
    I appreciate,

    I ordered this morning 2 chips ADC 0834...
    Can't wait to try something..

    Best regards,

    Maxb
  • MaxbMaxb Posts: 16
    edited 2005-03-18 22:17
    hi,

    I don't want to pay for a synthetizer...
    So
    Will it work if I buy an electronic keyboard at Toys'R'Us ?..
    even if there is no Midi inputs,
    Is there anybody who ever tryed this?
    If not,
    can I try something else?

    Thanks
    Maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-18 23:30
    It would be more work and expense to hack a cheap keyboard than to buy a MIDI-ready model -- you can get them at RadioShack for about $100. They certainly don't support the full MIDI spec, but you can "play" them with a BASIC Stamp sending MIDI commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-21 22:30
    Hi Jon,

    I haven't bought MIDI-ready model yet,
    little problems to resolve before I buy it ..

    I connected the ADC0834 with a BS2-SX using the National ADC datasheet...
    Pins are connected as follow :

    The thing is, I don't know what means SARS so, pin 11 (ADC0834) is not connected.
    Pin 1=5V+
    Pin 2= to pin 15 ( BS2-sx)
    Pin 3 Ch0
    Pin 4= Ch1
    Pin 5= Ch2
    Pin 6= Ch3
    Pin 7= Ground
    Pin 8= Ground
    Pin 9= 5V+
    Pin 10= Connected to Pin 13 (ADC0834)
    Pin 11= SARS ??
    Pin 12= to pin 13 BS2-sx
    Pin 13= Connected with pin 10, plus one resistance (1K) to pin 14 BS2-sx
    Pin 14= 5V+


    I took your code that you gave me, and before using pots,
    I tryed to receive a signal from my proxi sensor.
    I checked with the voltmeter, and there is a voltage variation...

    Except that with the debug command, I am receiving
    CS0: 00
    CS1: 00
    CS2: 00
    CS3: 0
    and, no results at all in HEX2..

    I presume that it must be pin 11 SARS??
    I will try to find what it means

    What sould I do.?.

    Thanks again,
    Regards

    Maxb
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-21 23:56
    What should you do? Connect the pots as I suggested before so you can get the ADC code working first. Trying to troubleshoot the ADC with a variable input is just plain ... well, silly. Use the pots, it will save you time in the long run. Once you get reliable data from your ADC channels, THEN you can connect variable voltages to the inputs of the ADC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • MaxbMaxb Posts: 16
    edited 2005-03-23 17:01
    hi Jon

    I resolved my debug problem by changing the microcontroler.
    Instead of using the BS2, with the code you gave me,
    I took the BS2-sx.
    You might ask me why??
    Here's the answer:

    Bread board + wires + Board of Education
    or
    BS2-sx on the Bread board
    which is more useful....but not for the code..my mistake
    sorry for this.

    Regards,

    Maxb
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-24 20:56
    I'm guessing the problem with the A2D use of the 8-pin PIC was a grounding problem. If you saw noise with an o-scope or voltmeter, then you saw 'real' noise -- perhaps switching noise of the PIC coming up and down? When in 'sleep' the PIC would set all its pins to input, no? When woken, it would put its pins into 'analog sensor' mode -- might trigger an o-scope.

    It's too bad, it should have worked. It's a really neat hack, in any event.
  • MaxbMaxb Posts: 16
    edited 2005-03-29 17:17
    hi,

    Still a few days before my final presentation...
    and my goal is to present a little program using force, and proximity sensors as inputs
    and LEDs sound volume as outputs.

    I received a helpful code from Jon Williams for the ADC0834,
    and two PDF documents on MIDI. (Column #94-95).
    I almost understand the code, but...
    I have some questions, here's the most important ones

    I adapted the code to my project,
    but I don't know how to put some LEDs ON because I get
    4 results in Dec3 from ADC0834 with the Debug command.

    See the code at the Jon Williams' previous message
    File Attachment :
    ADC0834.BS2.TXT · 2KB (text/plain)

    I want to use a "If... Then" loop after debugging results,
    I read that the value of an analogue input can be easily copied into a
    variable by use of the READ command.

    Let's say READ 100, ..?.. ' retrives the value at location 100, and stores it into the variable called..?.
    What variable should I put? if I have one variable BYTE that gives 4 results Ch0, Ch1, Ch2. Ch3.

    The other question is concerning the code for MIDI outputs.
    I want to increase the sound volume when many variations of the distance are recorded
    For exemple, when the head moves back and forth every 2 seconds, the proxi sensor detects it,
    The results are between 141 and 76, and I want to increase volume depending on the time and the distance

    A little big help would be appreciate!

    I will send a part of my code of MIDI in 2 hours

    thanks

    Maxb
Sign In or Register to comment.