Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:57 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Any idea why this isn’t working?

Author Message
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 07:35pm 08 Aug 2020
Copy link to clipboard 
Print this post

Trying to read a midi signal from com1, the manual doesn’t give much detail on reading com signals so I adapted the basic temperature sensing example, but not getting anything printed to screen when data is sent. I am a total newb at this so probably something I’m overlooking.




I have checked the hardware connections and they are correct and the sending device is sending correctly, so obviously my code is crap  
 
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 07:41pm 08 Aug 2020
Copy link to clipboard 
Print this post

Update - when I send a lot of data I get an error: Line is too long
So it seems like the com 1 is receiving the data but it isn’t printing it to the screen, basically I want it to print each time it receives any data.
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 08:12pm 08 Aug 2020
Copy link to clipboard 
Print this post

Line Input will wait for a carriage return character before returning your input data.  Have a look at the Input$ function.  Also CHR$ is a reserved keyword and shouldn't be used like this.

Try something like this in your do loop:

C$ = Input$(1,#1)
Print C$;
Edited 2020-08-09 06:21 by Sasquatch
-Carl
 
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 08:31pm 08 Aug 2020
Copy link to clipboard 
Print this post

Much thanks @sasquatch I am at least now getting data on the screen, the data is not in the correct format though so I guess now I need to figure out how to convert the raw serial midi input (hex?) to meaningful data, possibly something to do with setting up the com port parameters?

Any idea on that, and again thanks for the help
 
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 08:44pm 08 Aug 2020
Copy link to clipboard 
Print this post

I think I need to set com parameters for 1 start bit (0), 8 data bits, 1 stop bit (high).
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 08:45pm 08 Aug 2020
Copy link to clipboard 
Print this post

CHR$ is a reserved word. Use a different name for your variable.

Also, what is the physical connection? What are the voltage levels, polarity, etc. The CMM2 (that I think you are using) expects 3.3 volt signals, idle low? High? I'm not sure. What about the midi end?

If the data is coming in as binary, you might want to convert it to something you can see and recognize:
C$ = Input$(1,#1)
Print HEX$(ASC(C$),2) " ";
Edited 2020-08-09 06:58 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 09:20pm 08 Aug 2020
Copy link to clipboard 
Print this post

@vegipete the  physical connection is a midi breakout board operating at 3.3v levels connected to the com 1 pins on cmm2 gpio.

I tried your amendments and I’m getting a constant stream of zeros on the screen, this is good because it means that it is detecting the midi signal, as when I send events they are appearing in the sea of zeros.

I think the default com port settings need changing, the zero I think is the start bit, more info on the midi serial protocol here https://learn.sparkfun.com/tutorials/midi-tutorial/all#the-midi-standard

Basically the end aim is to have a midi message monitor, with filtering of data by channel and type, it should be quite a handy utility for anyone into midi for troubleshooting and analysis and of course when it is finished I’ll make it available for anyone who wants it, along with details of the circuit required.

Problem at the minute (in case not painfully obvious) is I know what I want to do but have no idea how to do it, I have ordered some printed manuals which I hope will make things a bit easier, trying to view them on my phone is a bit difficult, plus I’m a paper manual guy anyway, can’t deal with scrolling when flipping back and forth between pages is much quicker and simpler  
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 09:48pm 08 Aug 2020
Copy link to clipboard 
Print this post

I don't know MIDI but my quick reading (including the sparkfun site you linked) doesn't seem to indicate that a stream of zeros is normal.

Maybe try the following to ignore zeros and see what is left. This won't work for real data because zero is valid data sometimes but hopefully sensible bytes should be visible when you press a key...

C$ = Input$(1,#1)
CA = ASC(C$)
if CA Print HEX$(CA,2) " ";
Visit Vegipete's *Mite Library for cool programs.
 
Daren
Newbie

Joined: 05/08/2020
Location: United Kingdom
Posts: 25
Posted: 10:10pm 08 Aug 2020
Copy link to clipboard 
Print this post

  vegipete said  
C$ = Input$(1,#1)
CA = ASC(C$)
if CA  Then Print HEX$(CA,2) " ";


I got a missing Then error message, so added as shown and now it seems to be only reacting to the key press, so thats another bit of progress, thanks Pete. The data is still “garbage” but alphanumeric rather than the random characters from before, so again headed in the right direction, I think the message protocol is going to take a bit of work to decipher, but I’m actually stoked that the data is being read by the CMM2. I have also sent data from the com1 via midi, so already (me being a midi user) the CMM2 is looking like it has lots of interesting possibilities.

Thanks again!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025