Midi Problems 2 (pic16f887 and 16f877)

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
festjejo
Posts: 5
Joined: Wed Nov 21, 2012 12:10 pm
Contact:

Midi Problems 2 (pic16f887 and 16f877)

Post by festjejo »

Hi All,

I've been trying to set up communication through midi.
Sending from the E-block is no problem. I'v used the MMM delivered programs.
I've also created a midi clock signal sending 24 clocks/sec.
I can read these sigals out with the MIDI-OX console on my PC.
The timestamps form the CLK signal match perfectly with the sent data.

On the other hand when I try to receive midi code from MIDI-OX and display it on the LCD E-block,
I get crappy stuff, or nothing at all. I've used every MMM program : Midi_monitor, Slave, Slave_HW and Midi_rx.
I adapted parameters in the programs, I've been tweaking the delays without any change in the received data.
The Status Byte is nearly always 32. The same message appears different every time it is sent. I used 2 diffent PIC types...

Kind of running out of ideas here...

I didn't tweak the CPU clk, for the sent data is clocked in well and Timestamps match perfectly.
Can't find extended CPU info in data sheets??

Other known issues, possible solutions?
Help please!
Tx.



First of all you have the Use Extended CPU config bit enabled. This is known to cause problems so I would recommend that you disable this option.

Secondly there are a couple of defines that control the baud rate of the bit banged MIDI signal.

For a clock speed of 19660800Hz

//MIDI Bit and Half Bit Delays
#define MIDI_TX32_US 41
#define MIDI_RX16_US 20

And for a clock speed of 12000000Hz.

//MIDI Bit and Half Bit Delays
#define MIDI_TX32_US 20
#define MIDI_RX16_US 9

If you select the MIDI component on the panel then you can right click it and select custom code. Then select the GetDefines section and click Edit.

Once in here you can then change the values assigned to the baud rate to see if you can tweak it slightly to make it work more reliably.

//MIDI Bit and Half Bit Delays
#define MIDI_TX32_US %e
#define MIDI_RX16_US %f

Eg change to

//MIDI Bit and Half Bit Delays
#define MIDI_TX32_US 12
#define MIDI_RX16_US 5

As the signal is bit banged it is based on delays which are based on the crystal frequency. We have a calculation which generates the delay values but sometimes tweaking the values slightly allows for a more reliable connection.

If you have an oscilloscope then you can test the data. The baud rate should be as near to 31250 bits per second as you can get it.

Hope this helps.

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: Midi Problems 2 (pic16f887 and 16f877)

Post by Benj »

Hello,

Hm is there any way of knowing what data is being sent to the device and this way maybe we can spot why the status byte is nearly always 32 or 0x20.

I would always disable the extended CPU config option as it seems to cause problems with things like arrays unless you are calling functions specific to the extended CPU which Flowcode does not currently support.

festjejo
Posts: 5
Joined: Wed Nov 21, 2012 12:10 pm
Contact:

Re: Midi Problems 2 (pic16f887 and 16f877)

Post by festjejo »

Tx, but :
disable the extended CPU config option
Can't find extended CPU info in data sheets??
Can you help me with that? Howto disable?


Command is 0x20 where it should be 0x9* ( note on).
It has been different for other commands, but it switched from one to another for the same command.
Unstable thus.

tx
fest.

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: Midi Problems 2 (pic16f887 and 16f877)

Post by Benj »

Hello,

Please can you tell me which version of Flowcode you are using? Might also be helpful if you can attach your program so far so I can have a quick check.

festjejo
Posts: 5
Joined: Wed Nov 21, 2012 12:10 pm
Contact:

Re: Midi Problems 2 (pic16f887 and 16f877)

Post by festjejo »

Hi,

that is FLC v5.4.0.0 pro license.
program is :
1. MIDI Monitor.fcf
unstable data
(17.77 KiB) Downloaded 403 times
or :
Slave_HW.fcf
unstable data
(15.96 KiB) Downloaded 386 times
and :
Midi_rx.fcf
No received data
(12.5 KiB) Downloaded 398 times
tx.

festjejo
Posts: 5
Joined: Wed Nov 21, 2012 12:10 pm
Contact:

Re: Midi Problems 2 (pic16f887 and 16f877)

Post by festjejo »

picture:
MIDI_RX_trouble.png
MIDI-OX send, MIDI Rx receive.
(186.72 KiB) Downloaded 2824 times

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: Midi Problems 2 (pic16f887 and 16f877)

Post by Benj »

Hello,

Would flicking the MIDI to use a hardware UART rather then the software one be an option for you? This should give you much more time to play with and should be a bit more reliable for a fixed baud such as MIDI.

There is currently no option to do this via the MIDI component properties so you have to go the custom code way.

Select the MIDI component and click Custom Code.

Then select the Defines function and click Edit.

Then find the 4 lines that look similar to this.

#define MX_UART_CHANNEL_1 %b
#define MX_UART_CHANNEL_2 %b
#define MX_UART_CHANNEL_3 %b
#define MX_UART_CHANNEL_4 %b

Note the lines are not all together in the function.

And change them to this.

#define MX_UART_CHANNEL_1 1
#define MX_UART_CHANNEL_2 1
#define MX_UART_CHANNEL_3 1
#define MX_UART_CHANNEL_4 1

This will override the definitions to allow you to use the hardware UART. The hardware UART pins can be found by looking at the chip diagram in Flowcode and searching for TX and RX.
View -> Chip.

festjejo
Posts: 5
Joined: Wed Nov 21, 2012 12:10 pm
Contact:

Re: Midi Problems 2 (pic16f887 and 16f877)

Post by festjejo »

That did the trick!

Tx, Benj!

Very happy with that...

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

Re: Midi Problems

Post by joeflickers1234 »

hi matrix multimedia,i am developing a midi controller for software such as ableton live and virtual DJ,i am sending CONTROL CHANGE MIDI message when i move a potential meter at the analogue input pins.im using pic18f2550.when the CONTROL CHANGE VALUE is less than BYTE 4,an error is indicated message is indicated by the serial to midi converter software.im using hairless midi converter software.this messes up the the software.
please help out.iv attached the project
Attachments
final synth.png
(139.99 KiB) Downloaded 1811 times
hairless shot.png
(56.62 KiB) Downloaded 4308 times
final midi synth.fcfx
midi controller fcf file
(20.6 KiB) Downloaded 269 times

Post Reply