FC6 MIDI RS232 / USB

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

FC6 MIDI RS232 / USB

Post by Rudi »

Hi
i try a simple
i have try in RS232 to receive MIDI Data.. but the Bug in 0 Bytes was in RS232
so i try it with MIDI_Compo..
i will read MIDI Data in in this example with MIDI Compo. ( if RS232 better go - i will change to it )
I have a MIDI Shield at UART or Software UART - all two i try...

Midi_in Data will send return ( Midi True )

if i press a button..
the midi_in data will send over usb serial.

1. test
without midi:out over usb

all is fine.

2. test
if i play slow.. all is fine
if i play fast.. the midi data will shake.

i have test with RS232 too without usb.
the same..

what make i wrong

i will simple send midi_in to midi_out and over RS232 ( HW or Software 38400 )

I need help ;-)
i am try three weeks at this ;-)
i have more as over 130 try in and over RS232..USB Slave..HID.. and MIDI compo
i am foxi ;-) now ...

please - what is wrong with the simple sample code?
or who can give me a hint or edit ..


I will send MIDI DATA what incommes back to RS232 in 38400 baud..
as a MIDI Bridge...
Thank you!!!

Best wishes

Rudi
;-)

PIC18F2550 / 20 Mhz

48 MHZ Takt..

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: FC6 MIDI RS232 / USB

Post by Benj »

Hi Rudi,

I've added a timer interrupt and circular buffer component to take care of the USB comms and the MIDI transmission. There might still be problems when receiving data while transmitting so let me know how you get on.
Attachments
FC6_MIDIKOMPO_USB2a.fcfx
(11.62 KiB) Downloaded 260 times

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: FC6 MIDI RS232 / USB

Post by Rudi »

Benj wrote:Hi Rudi,

I've added a timer interrupt and circular buffer component to take care of the USB comms and the MIDI transmission. There might still be problems when receiving data while transmitting so let me know how you get on.

"Where is the 1000 Thanks Button ?"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

;-)

Hi Benj,,

first - have a big thank from me to you for your help and time -


i have try your example - i have note your very very good thinking with buffering and have understand the principal - .. thank you for this instruction!!!
..
I have test it - but TIMER0 don't fire..

i have test with Timer1 but Timer1 is ..i think is to slow ( 1:1 183.105 HZ )
i get over usb 2 bytes...but i get it ;-)) ..your buffering will go on to work..

my "TIMER0" do not fire - i do not know why -
i have then test in simple two examples i append here.
in TIMER0Test the Timer do not fire
in TIMER1Test the Timer fire

i have make simple controll with sw1 ( RA4 ) and sw2 ( RA5 )

if timer is fire then call macro for led on/off - macro will test sw1 ..is high the portb0 will show me this with LED on is sw1 low the portb0 will show me this with LED off

a test sw is sw2 ..this simulate a fire for timer ...

only TIMER1 fire..

I think - i must set a right config byte for TIMER0

perhabs you have a little little time for a look to

http://www.bristolwatch.com/PIC18F2550/ ... 0_TMR0.htm

i have the same board for test with PIC18F2550.

I think i must first try to make TIMER0 ready in a simple LED on/off -
perhabs you know how this can be done -

PIC18F2550 with external 20MHZ
Clock: 48MHz

Config Bytes are
0: 0x24
1: 0x0E
2: 0x38
3: 0x1E
4: 0x00
5: 0x80
6: 0x80
7: 0x00
8: 0xFF
9: 0x80
A: 0xFF
B: 0xA0
C: 0xFF
D: 0xFF

I have read in "Setting up INTCON"
http://www.bristolwatch.com/PIC18F2550/ ... raries.pdf

and have note that

INTCONbits.TMR0

IF TMR0 Overflow Interrupt Flag bit must be cleared by software before another interrupt can occur.
Is this making by Macro Interupt TIMER0 byself or must this in the Code extra?

Thank you Benj very much for your help and your Time.

Best wishes!
Rudi

:-)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: FC6 MIDI RS232 / USB

Post by Benj »

Hello,

Hmm I can't figure out a reason why timer 0 would not be firing on this device. Looking at the C code produced it all looks fine.

I have just tested on a 18F4455 which is the same device family and it is working fine.

Comparing the C code it's identical so I'm a bit stumped?

Could you use timer 2 instead, it is an 8-bit timer rather then the 16-bit timer 1 so the interrupt frequency achievable should be much higher.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: FC6 MIDI RS232 / USB

Post by Rudi »

Benj wrote:Hello,

Hmm I can't figure out a reason why timer 0 would not be firing on this device. Looking at the C code produced it all looks fine.

I have just tested on a 18F4455 which is the same device family and it is working fine.

Comparing the C code it's identical so I'm a bit stumped?

Could you use timer 2 instead, it is an 8-bit timer rather then the 16-bit timer 1 so the interrupt frequency achievable should be much higher.

Hi Benj,

TIMER2 works,
i have test your sample with
Prescaler Rate: 1:1
Postscaler Rate: 1:8
Rollover Value: 256

Clock Speed: 48000000 Hz
Interrupt Frequency: 5859.375 Hz

If i play slow... ok.. the note will bufferd (FIFO ) and then Midi_out send to play and USB Serial ok
if i play little faster .. the bytes will "cut".. and missed ( 90 3C 7F -> 80 7F 00 ..) and midi_send / play will shake.
i will experiation with this... and will tune with attribute the Rates slower and higher..

Midi shield is ok -
( PC900 , 220 Ohm, 270 Ohm.....)
if i test it only with
MIDI_in -> Midi_out all ist ok.


btw:
can i make a Interrupt to Midi_In... and then start the FIFI Buffer Macro


Benj - ... it works principal ... TIMER2 works too.
I will you let know next steps and how is go one next..

Benj best thank to you!!!
You have more done like you "must" ;-) thank you for your friendly service!!!

Best wishes
Rudi
;-)

joeflickers1234
Posts: 6
Joined: Fri Apr 25, 2014 6:21 pm
Contact:

Re: FC6 MIDI RS232 / USB

Post by joeflickers1234 »

Hi rudi,we seem to be having a similar problem with midi transmit,im also using PIC18F2550 running at 48MHz,im using ft232 for serial communication and hairless midi software for serial to midi conversion.im sending midi control change message whose value is from an ADC .when the control change value nears zero,the the conveter shows midi error message.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: FC6 MIDI RS232 / USB

Post by Rudi »

joeflickers1234 wrote:Hi rudi,we seem to be having a similar problem with midi transmit,im also using PIC18F2550 running at 48MHz,im using ft232 for serial communication and hairless midi software for serial to midi conversion.im sending midi control change message whose value is from an ADC .when the control change value nears zero,the the conveter shows midi error message.
Hi joe,

is the FT232 support 31250 baud rate for MIDI ?
Or how you manage the Serial to Midi ?

In First Time :
I have the UART ( Channel 1 ) in PIC 18F2550 for the fast Baudrate 38400 as a transparent UART over a Wifi Shield ... this wifi send my midi to the PC ( DSMidi for the UDP Port forward to Midi Yoke )
and a Software Uart ( 31250 ) for the MIDI IN.
( Midi needs 31250 )

But this is not stabil.

So i change for Test
The Midi In i realized at UART ( Channel 1 ) and make a Software Uart but slower baud for test... ( 19200 ) .. and the wifi was working good.. but if i play fast.. the 19200 is not enough... and latenz will come on..

i test in a third with the PIC24
so i have two HW UART for this...
and this run at time for me good. but the Baudrate and USB Slaves i have not go on ... i will go on in this next time again - i have make a "sleep" to this .. i work with Component Build at Time... later i will go back here.. because i will make
this with Pic18F25550... ..the pic24 i need for OTG..

You wrote:
"im sending midi control change message whose value is from an ADC .when the control change value nears zero,the the conveter shows midi error message."
.
I understand it so:
You send Messages from an Extern Controller.. Example "B0 73" + Value example 0..127
and if you ( The controller ) send a "0" the midi message would be wrong?
..

you can change the string/byte to char 0x00 by your self, because in string the 0byte will not read just in time.. ..
..

best wishes
Rudi
;-)

joeflickers1234
Posts: 6
Joined: Fri Apr 25, 2014 6:21 pm
Contact:

Re: FC6 MIDI RS232 / USB

Post by joeflickers1234 »

Hi rudi,thanks for your fast reply,i dont understand the last part where you say i change the control value to 0*00 .im i supposed to change the midi byte value,
which version of flowcode are you using?im on the latest patch 6.0.7.i did check ft232 documentation and the maximum baund rate is 3mhz.btw im i also supposed to use a fixed a baund you specified.

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: FC6 MIDI RS232 / USB

Post by Rudi »

joeflickers1234 wrote:Hi rudi,thanks for your fast reply,i dont understand the last part where you say i change the control value to 0*00 .im i supposed to change the midi byte value,
which version of flowcode are you using?im on the latest patch 6.0.7.i did check ft232 documentation and the maximum baund rate is 3mhz.btw im i also supposed to use a fixed a baund you specified.
Hi Joe,

i work with the 6.0.6 ;-) . i will wait for the next update after 6.0.7 :-) .... ...
the 6.0.6 work at time fo rme like i need ;-) ...

sorry Joe,
i understand the FT232 so,
you transfer with this MIDI Byte's - right?
between a ADC ( Analog Digital Controller ) and a FT232 ..

The FT232 is connect to the PIC28F2550 ..
UART?
or PMP ( Parallel Master Port .. example 0..7 RB )
or SPI ?

how do you sort this bytes that comes from the ADC to the PIC18?
RS232?

Which Function does the FT232 do? Only a Briding from ADC to PIC or is the ADC a MIDI Controller with "FIX Baudrate in Midi ... : 31250 " ?

With RS232 Compo is a little Bug with 0 Byte
http://www.matrixmultimedia.com/mmforum ... 54&t=14345
and in String Converts..
http://www.matrixmultimedia.com/mmforum ... =7&t=14488

perhabs this is the reason for your?

normaly you can send and receive the 3 byte of midi "string"..example for a controller "events"
B0 3F 00 perfect in FC..

ReadString
3 Bytes..

mid // String[3]...String[20]
Status Byte = mid[0]
Event Byte = mid[1]
Value Byte = mid[2] / your near zero ..

the midi[2] in this will be the 00
but in the receive in "0" Byte the "0" Byte will not correcly read
so you must change this to char .. 0x00 is the HexCode of a Byte with value: 0
one possible is - you have the rs232 for ReadChar ...


Best wishes
Rudi
;-)

joeflickers1234
Posts: 6
Joined: Fri Apr 25, 2014 6:21 pm
Contact:

Re: FC6 MIDI RS232 / USB

Post by joeflickers1234 »

Hi,could you possibly send me a file example showing how to convert bytes to charcters..iv tried doing so,but the midi value is supposed to in bytes..
..iv used dswifi and it works without error with an application on my android(Dj control).iv also used arduino uno in their programming environment and it works well..ill appreciate..i
i can also attach my project u preview if it has bugs.

joeflickers1234
Posts: 6
Joined: Fri Apr 25, 2014 6:21 pm
Contact:

Re: FC6 MIDI RS232 / USB

Post by joeflickers1234 »

hie,iv attached the midi projects am up to,the midi value error if solved i would appreciat
Attachments
final midi synth.fcfx
midi attachment
(17.57 KiB) Downloaded 252 times

Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 493 times
Been thanked: 187 times

Re: FC6 MIDI RS232 / USB

Post by Rudi »

joeflickers1234 wrote:hie,iv attached the midi projects am up to,the midi value error if solved i would appreciat
Hi joe,

i will try to see your project at weekend on.

Joe, you used dswifi and it works without error with an application on your android(Dj control).....and also arduino uno in their programming environment and it works well?...
ok.. i think you take DS MIDI with port 9000 ? and Midi Yoke.....

hmh.. try this in a simple new project:

btw Only a question:
Why you take Midi."SendNoteOn" for ADC? ( note on allways 0x9..)
usually this is the same but...have a try to send by yourself a explicite NoteOff if Value = 0 .....

...

...Try...

command:

Midi."SendMidi"

Status // example..Byte...0x90....( same like Note On.{0x9} . and Channel 0 )
Data1 // example...Byte...0x32 ...(same like 50 ... if you need this Hex as 50 then you must write 0x50)
Data2 // example...Byte...0x7F ...(same like value 127 )

...Value > 0
Note On = 0x9

...Value = 0
Note Off = 0x8

Status // example..Byte...0x80....( same like Note Off.{0x8} . and Channel 0 )
Data1 // example...Byte...0x32 ...(same like 50 ... if you need this Hex as 50 then you must write 0x50)
Data2 // example...Byte...0x00 ...(same like value 0 )


example ( channel 0=1 ..1=2.......15=16 in hex the last channel will be 0x9F / 0x8F )
if you send 0x90 3C 00 then the most Midi will sort this for a "noteOff"...but not all...
so is better to send for a "noteOff".. 0x80 3C 00.. this is midi.org rules.... and perhaps this
can be the wrong near zero ( o ) ..

so if you send a value of "0"...so try to send not a Note On... try this
Midi.SendMid
Status...0x80 <----.this for Note Off ( channel 0 example )
Data1 ...0x50
Data2 ...0x00 <---- this for Value 0


i hope this help.

Best wishes!
Rudi
;-)

joeflickers1234
Posts: 6
Joined: Fri Apr 25, 2014 6:21 pm
Contact:

Re: FC6 MIDI RS232 / USB

Post by joeflickers1234 »

hi,id did remove the lcd component and the midi transimssion is working better,before it was very slow or did not work at all.however iv not been able to work out the sending of a correct midi control change value.currently its sending change value between 4_124(bytes)..value0_3, 125_127 are not recognized as correct midi.

Post Reply