Jump to content

MIDI Motor Controller


jefman
 Share

Recommended Posts

Hi all -

Just joined the forum. I'm working on designing a board to let me control motorized props with MIDI to move in time to music. The midibox/mios system looks really great, and I think it would be very useful for this. I've looked at the documentation quite closely, and I have a few technical questions that I could use some help with. The following is a bit long, but any advice would be appreciated, since of course I have a show coming up next week that I need to use this in!

I've already designed my own board using a 16F877, and programmed it in assembler to receive MIDI and control two motors using the hardware PWM (I need high-frequency PWM for the motors I'm using) through an L298 dual H-bridge board. It seems to work quite well.

I've decided to build a new version using the 18F4331, which is almost the same as the 18F452, except that it has six hardware PWM channels. I have no problem to make my own design and code for it, but I'd rather take advantage of all the great programming and peripherals of the midibox.

So here's what I'd like to do:

First, I would replace the 18F452 on the midibox core board with the 18F4331.  There would be a bit of a change in the mios code in terms of setting up the analog ports, but that should be easy. Other than that the pinout is the same, except the synchronous serial port is moved, but I think mios doesn't use that (curious, why not use the hardware i2c instead of bit-banging on J4?)

What about the bootloader? Would it work with this chip? Is the source available for that? I couldn't find it.

I'm already halfway through designing a board with three L298 dual h-bridge motor controller chips, and this could attach to J15 on the core (so I would use an i2c connection for an LCD). I'll need all the pins on J15 for PWM, except for port D<5>. I also need port C<1:2>, since that's where two of the PWM pins are. So I would also use J7 from the core module; I would use C<0> also on J7 as an enable pin for the motor controller chips. So far I think this should all be ok, and the code to do the hardware PWM output is not very intense.

But now I start to push the limits: I still want to be able to use the motorfader board. I might use it with actual motorfaders, but also I might just use it to control some small hobby motors. Then I wouldn't need the position feedback, just the software PWM (some hacking of the motorfader code, but also not so difficult I think). And so in that case I would also want to use the AIN multiplexer board to connect a bunch of sensors (knobs, and other things like accelerometers, etc.)!

I thought it might be possible to connect the motorfader board to J10 instead of J7. However, it looks like the serial clock on D<5> is shared by the i2c interface to the banksticks etc. - I guess J10 works ok with the AOUT board because there's a chip select signal to it? And it doesn't bother the LCD "RS" line for some reason? But am I correct that J10 could not be used for the motorfader board, since any bankstick access would clock data into it? (I can't use D<6> for the clock since that's one of the PWM outputs).

Maybe I could use J10 for the AIN module addresses (instead of J6)? At least I could just not take any analog reading while bankstick access was happening? But I guess this could be a problem if I'm using an i2c LCD, it might interrupt the AIN readings too much...

Well maybe I'm trying to do too much at once, but I'm on a hunt for a couple of extra pins. What if I use C<3> from J6 and C<4:5> from J10 for the motorfader control. And then for the AIN control, I could use... what? Would it be possible to share D<0> (SO on J8) with SO for the motorfader? I mean, you are never clocking both the motorfader and J8/J9 at the same time, right? Maybe that could give me an extra pin? And what about D<4> - I'm not sure what the touch sensor is used for? Ah, but I still need one more! Maybe I can take one or two of the analog pins, and limit the analog inputs to 56 or 48 instead of 64. Well at this point the wiring starts to get pretty weird, and I start to think about designing my own core board... but I that's probably more work than I want to do right now... any ideas?

Thanks... <Jeff

Link to comment
Share on other sites

Hi all -

Just joined the forum. I'm working on designing a board to let me control motorized props with MIDI to move in time to music. The midibox/mios system looks really great, and I think it would be very useful for this. I've looked at the documentation quite closely, and I have a few technical questions that I could use some help with. The following is a bit long, but any advice would be appreciated, since of course I have a show coming up next week that I need to use this in!

I've already designed my own board using a 16F877, and programmed it in assembler to receive MIDI and control two motors using the hardware PWM (I need high-frequency PWM for the motors I'm using) through an L298 dual H-bridge board. It seems to work quite well.

I've decided to build a new version using the 18F4331, which is almost the same as the 18F452, except that it has six hardware PWM channels. I have no problem to make my own design and code for it, but I'd rather take advantage of all the great programming and peripherals of the midibox.

So here's what I'd like to do:

First, I would replace the 18F452 on the midibox core board with the 18F4331.  There would be a bit of a change in the mios code in terms of setting up the analog ports, but that should be easy. Other than that the pinout is the same, except the synchronous serial port is moved, but I think mios doesn't use that (curious, why not use the hardware i2c instead of bit-banging on J4?)

What about the bootloader? Would it work with this chip? Is the source available for that? I couldn't find it.

I'm already halfway through designing a board with three L298 dual h-bridge motor controller chips, and this could attach to J15 on the core (so I would use an i2c connection for an LCD). I'll need all the pins on J15 for PWM, except for port D<5>. I also need port C<1:2>, since that's where two of the PWM pins are. So I would also use J7 from the core module; I would use C<0> also on J7 as an enable pin for the motor controller chips. So far I think this should all be ok, and the code to do the hardware PWM output is not very intense.

But now I start to push the limits: I still want to be able to use the motorfader board. I might use it with actual motorfaders, but also I might just use it to control some small hobby motors. Then I wouldn't need the position feedback, just the software PWM (some hacking of the motorfader code, but also not so difficult I think). And so in that case I would also want to use the AIN multiplexer board to connect a bunch of sensors (knobs, and other things like accelerometers, etc.)!

I thought it might be possible to connect the motorfader board to J10 instead of J7. However, it looks like the serial clock on D<5> is shared by the i2c interface to the banksticks etc. - I guess J10 works ok with the AOUT board because there's a chip select signal to it? And it doesn't bother the LCD "RS" line for some reason? But am I correct that J10 could not be used for the motorfader board, since any bankstick access would clock data into it? (I can't use D<6> for the clock since that's one of the PWM outputs).

Maybe I could use J10 for the AIN module addresses (instead of J6)? At least I could just not take any analog reading while bankstick access was happening? But I guess this could be a problem if I'm using an i2c LCD, it might interrupt the AIN readings too much...

Well maybe I'm trying to do too much at once, but I'm on a hunt for a couple of extra pins. What if I use C<3> from J6 and C<4:5> from J10 for the motorfader control. And then for the AIN control, I could use... what? Would it be possible to share D<0> (SO on J8) with SO for the motorfader? I mean, you are never clocking both the motorfader and J8/J9 at the same time, right? Maybe that could give me an extra pin? And what about D<4> - I'm not sure what the touch sensor is used for? Ah, but I still need one more! Maybe I can take one or two of the analog pins, and limit the analog inputs to 56 or 48 instead of 64. Well at this point the wiring starts to get pretty weird, and I start to think about designing my own core board... but I that's probably more work than I want to do right now... any ideas?

Thanks... <Jeff

Link to comment
Share on other sites

Hi Jefman,

Use of the 18F4331 as a replacement for the 18F432 doesn't seem feasible for MIOS. MIOS, as it stands now, uses about 12K bytes of flash and the 18F4331 has only 8K bytes of flash. However, since you need the PWM capabilities of the 18F4331 perhaps you could use it for the motor control functions and utilize the MIDI merger code and MBLink to communicate with a standard core module. Using this arrangment, the 18F4331 would connect to the MIDI in from the outside world and would pass incoming MIDI that is not used by the motor controller through to the core.

If you setup the LCD to use 4-bit mode you can obtain four more pins (port b<0:3>) to be used for other purposes. Thorsten's excellent coding techniques allow changing pin assignments quite easy.

The dual use of D<5> for I2C and RS is not a problem since the RS bit to the LCD only has meaning when the E bit to the LCD is toggled. Since the bankstick code and the LCD code execute seperately no interference occurs. Further, the I2C protocol will ignore the SC changes when the LCD is being used since the changes will not be recognized as valid I2C messages.

Hope this helps :)

Regards, Synapsys

Link to comment
Share on other sites

Hi Jefman,

Use of the 18F4331 as a replacement for the 18F432 doesn't seem feasible for MIOS. MIOS, as it stands now, uses about 12K bytes of flash and the 18F4331 has only 8K bytes of flash. However, since you need the PWM capabilities of the 18F4331 perhaps you could use it for the motor control functions and utilize the MIDI merger code and MBLink to communicate with a standard core module. Using this arrangment, the 18F4331 would connect to the MIDI in from the outside world and would pass incoming MIDI that is not used by the motor controller through to the core.

If you setup the LCD to use 4-bit mode you can obtain four more pins (port b<0:3>) to be used for other purposes. Thorsten's excellent coding techniques allow changing pin assignments quite easy.

The dual use of D<5> for I2C and RS is not a problem since the RS bit to the LCD only has meaning when the E bit to the LCD is toggled. Since the bankstick code and the LCD code execute seperately no interference occurs. Further, the I2C protocol will ignore the SC changes when the LCD is being used since the changes will not be recognized as valid I2C messages.

Hope this helps :)

Regards, Synapsys

Link to comment
Share on other sites

Oh. Well that kind of puts a damper on things.

Nevermind.

Guess there's no large chunks of code I could strip out...

Also I just noticed in the FAQ that you *must* use the bootloader, which I guess is not working with the 18F4331.

I suppose I'll have to forget about using MIOS for this.  :(

Well, thanks for the info...

cu later <Jeff

Link to comment
Share on other sites

Oh. Well that kind of puts a damper on things.

Nevermind.

Guess there's no large chunks of code I could strip out...

Also I just noticed in the FAQ that you *must* use the bootloader, which I guess is not working with the 18F4331.

I suppose I'll have to forget about using MIOS for this.  :(

Well, thanks for the info...

cu later <Jeff

Link to comment
Share on other sites

  • 9 months later...

Hi all -

Just got reminded about this thread...

I'm still interested to learn whether it's possible to port MIOS to a PIC18F4431.

I did end up designing and building my own core board using the 18F4431, plus H-bridge/PWM module boards for up to six 2A motors for robotics control. I made it at least partially compatible with midibox modules, in the hardware. Here is a photo of it: http://www.interaccess.org/jefman/motorboard.JPG

But I just programmed it myself in assembly, which did what I needed at the time (run the motors), but never got MIOS to run on it in order to use midibox modules too, like DIN/DOUT/MF, etc. - now I have some time and I'd like to see if I can make it work.

The 18F4431 has 16kB of flash, is that enough for a MIOS application?  (in the first post I made the mistake of saying PIC18F4331 that has only 8kB).

And what about the bootloader, since I guess it is not open-source? Is it really true that it is impossible to use MIOS without the bootloader? Is it possible in some way to adapt the bootloader to the 18F4431?

Thanks... <Jeff

Link to comment
Share on other sites

Hi Jeff,

But I just programmed it myself in assembly, which did what I needed at the time (run the motors), but never got MIOS to run on it in order to use midibox modules too, like DIN/DOUT/MF, etc. - now I have some time and I'd like to see if I can make it work.

Do you know more details why MIOS doesn't run on this chip?

The 18F4431 has 16kB of flash, is that enough for a MIOS application?

normaly not, you have to downstrip MIOS (e.g. remove the routines for graphical LCDs), and you have to put the "application" directly into the MIOS source in order to save memory.

And what about the bootloader, since I guess it is not open-source?

You can download it from the CVS - here a link to the web interface: http://cvs.sourceforge.net/viewcvs.py/mios/mios/

Is it really true that it is impossible to use MIOS without the bootloader?

It is possible to use MIOS without bootloader, but this means that MIOS itself cannot be updated via MIDI, and that a PIC programmer has to be used instead. This is much less comfortable, and especially slower than updating the code via MIDI.

Is it possible in some way to adapt the bootloader to the 18F4431?

Yes, just search for "PIC_DERIVATIVE_TYPE" in the bootstrap loader and MIOS source code

These are the places which have to be adapted

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...