I really hate to start another thread about DOUTs as I really thought I had this figured out but I apparently haven’t. What I have is the core module and a DOUT module from smashtv. I have finally gotten the compiler to work after following the wiki and this link http://www.midibox.org/forum/index.php?topic=7238.0. I was able to compile the skeleton without any trouble. What I am trying to do is turn on 8 different relays depending on which note is send by midi (notes being C4 to C5 no sharps or flats). I started out simple by just writing the program to turn on the LED on DO and VS of the DOUT module when a midi event was received. Here is the program:
// $Id: main.c 333 2008-05-10 20:49:56Z tk $
/*
* MIOS SDCC Wrapper
*
* ==========================================================================
*
* Copyright (C) <year> <name> (<email>)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
#include <cmios.h>
#include <pic18fregs.h>
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
// set shift register update frequency
MIOS_SRIO_UpdateFrqSet(1); // ms
// Up to 4 DOUTX4 modules (=16 shift registers = 128 digital outputs) can be connected
// set the maximum number here - it doesn't really hurt!
MIOS_SRIO_NumberSet(4);
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS in the mainloop when nothing else is to do
/////////////////////////////////////////////////////////////////////////////
void Tick(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is periodically called by MIOS. The frequency has to be
// initialized with MIOS_Timer_Set
/////////////////////////////////////////////////////////////////////////////
void Timer(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when the display content should be
// initialized. Thats the case during startup and after a temporary message
// has been printed on the screen
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Init(void) __wparam
{
MIOS_LCD_Clear();
MIOS_LCD_CursorSet(0x00);
MIOS_LCD_PrintCString("Hello World!");
}
/////////////////////////////////////////////////////////////////////////////
// This function is called in the mainloop when no temporary message is shown
// on screen. Print the realtime messages here
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Tick(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
MIOS_DOUT_PinSet(0, 1);
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has been received
// which has been specified in the MIOS_MPROC_EVENT_TABLE
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyFoundEvent(unsigned entry, unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI event has not been completly
// received within 2 seconds
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyTimeout(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a MIDI byte has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedByte(unsigned char byte) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after the shift register have been loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Finish(void) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when an encoder has been moved
// incrementer is positive when encoder has been turned clockwise, else
// it is negative
/////////////////////////////////////////////////////////////////////////////
void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam
{
}
/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
}
As you can tell this is just the skeleton wrapper with the Init and Event modified. This didn’t work. I have tried various different things, even putting the MIOS_DOUT_PinSet(0, 1); statement in the Init section, hoping to get the light to turn on when I power the board up. No success. Now for the rest of the details:
- R5 DOUT board from smashtv
- R4 CORE board from smashtv
- The PIC16F452 was bought separately and I programmed the bootloader and then uploaded MIOS via MIOS Studio
- Every time I power up the board I get the one sysex message.
- After that I did a hex upload of the compiled program above
- If you look at the CORE board with the midi connectors facing away from you I have wired the CORE to the DOUT in left to right order when the DOUT is facing so the J1 is the farthest from you but on the inside row of J1 (if you need a pic let me know)
- The led will flash once when I plug in the power supply to the CORE but will never turn on again
- For the initial “led comes on when a even is received” the keyboard from MIOS and the keyboard from MIDI-OX were used to send the midi command 90 3C (note on, C4)
I am really amazed at all this board can do, I really want to build a SID even thought I don’t know what it is used for right now. I’m not new to electronics only to midi circuits and midi music creation. I know it will be a while before I even attempt at making a SID or begin to understand what it does though I will keep reading until I do because this site and project really intrigues me. I really would have looked for about another two days before asking this question but I am working on this project for a friend and is due in about seven days.
PS In case your wondering, the application for this project is for my friends finial project for a visual arts, He was allowed to choose anything he wanted and get help from people to build it, the only requirement was that it contained lights. What he wanted to do was have a light show that was programmable by some software on the computer and have it flash lights to the music played. I have been experimenting with microcontrollers and doing electronics (for about four years on the general electronics and about a year in microcontrollers, just a tinkerer, nothing big, one past project, wireless gate opener) and I suggested he use midi so that is how I found this site. The light show will work like this: He will program the light patterns into a MIDI track in Sony Acid using the notes mentioned above then it will output it to the CORE and it will translate to a digital output via the DOUT module which will then switch opto-coupled triacs to control six 120VAC 50W light bulbs.
Thanks for any help you have to offer as it will be greatly appreciated,
Albert