News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Splitting an 8-bit port in two

Started by glenlivet, May 02, 2025, 07:33 PM

Previous topic - Next topic

glenlivet

I'm designing a 5-octave (61-notes) keyboard for an analog synthesizer project. The Demux part of the actual keybed to determine which key/note was pressed is pretty straight forward. Here's where it starts to get hairy. I want the output of the keyboard to be old school 1-Volt/Octave analog- standard for all synth VCO's.
The way I achieved this is to use a voltage divider made up of a string of 0.01% resistors (12 per octave) driven by a fixed current source that will set the division of the voltage divider at 1/12 volt per step or 0.08333 volts. The way I pick off the correct note voltage from the divider is with four 16 to 1 analog demultiplexers. I'm attempting to keep the pin count on the PIC as low as possible. Each demultiplexer rquires four address lines and one enable line to put the voltage on the common buss. So finally- is there a way to configure the lower four bits b0 to b3 of a port as a four bit data bus to set the value of the demux input pin and assign a port name to it and also assign an alias to the remaining upper four bits that will be used as an enable for each of the four demux chips? I have the prototype working on an 8-bit port by using the lower 4-bits as the demux address and the upper 4-bits assigned as an enable to each of the four demultiplexers. I output the value of the input pin on the demux that has the selected note and then do an "and" to set the enable bit b4-b7 for the correct demuxer that has the note but the code is really getting unwieldy and I only have 2 octaves up and running.       
 

Stephen Moss

You might want to try using hte forum serach as I think somehting similar has been asked before and there may be an alternate and possibly better solution to this but if you were using, say port B I think you can use...
Dim Demux_Select as PortB.LowByte
Dim Demux_Enable as PortB.HighByte

Although if you using an 18F, PIC24 pr PIC32 device you would usually use LATB for writing and PortB for Reading

See_Mos

#2
Is this monophonic or polyphonic?.  Using the OR manipulator should make it easier?  Manipulating the port directly would cause tiny output glitches so I have used a variable 'Temp'

Temp = IC_Select <<4         ' assuming the chip select value is 0 to 15 in the lower bits of a byte
Temp = Temp OR Output_value   ' add the control bits
LatB = Temp                  ' and load the output register

you could also use

Dim IC1 as %00010000
Dim IC2 As %00100000
Dim IC3 As %01000000
Dim IC4 As %10000000
Temp = IC1 OR Output_Value  ' change ICx to suit
LatB = Temp

Decoding notes using a data table or lookup table with a value for each note would be another way, or am I on the wrong track?


See_Mos

#3
What de-mux IC are you using?

Looking at the 4067 demux the above should work by changing the control / inhibit values to %1110 0000 for IC1 etc.

Apologies if anyone read post#3 while I was busy editing and modifying ideas.


See_Mos

I had a play with the idea in ISIS simulator and the code works but when the enable pin is high the output pin is disconnected from all inputs so connecting the output of one IC to X12 input of the next IC to use 'daisy chaining' four devices does not work.

Pepe

demo proteus