shaduzlabs / synapse

Arduino CV/Gate I/O shield and its software library
Other
80 stars 11 forks source link

Use of Synpase (examples, etc) #4

Closed thopa closed 6 years ago

thopa commented 6 years ago

Hi, Congrats on your device. I have built two. Im having some trouble using both of them. Would it be possible to post some user examples like a sequencer or a vco alsa ardcore where users can see how ports and voltages are used? Many thanks.

icnagy commented 6 years ago

I think it wouldn't be too hard to modify https://github.com/sneak-thief/Tombola_Euclidean_Sequencer to work with Synapse.

thopa commented 6 years ago

Hi Igcnacy. I know the work of Tom, and also now him personally. I dont really get your point, im just asking for a some easy user implementation of the synapse cv board. Surely the euclidean is not one of them? Thanks

icnagy commented 6 years ago

Hi Phato!

I am a bit confused now on what exactly you're looking for. You've said, you built two and "having some trouble using both of them". Could you elaborate a bit? Do you have an example code that is not working as expected? I have no issue using the one I've built. I can send out gate and CV signals as well. (I haven't tried the gate/cv ins yet)

I used the sequencer as an example, because it is a working code base and it is well documented (or commented). But you're right, that it's not a basic example.

If you're looking for a "hello world", a simple sketch is included with the library (https://github.com/shaduzlabs/synapse/blob/master/examples/Test/Test.ino) that will do a sweep on both CV outs and a gate flip on both gate outs. Do you have trouble running this?

thopa commented 6 years ago

Hi! Thanks for your reply! Yes i have tried using the test.ino file ansd it works fine. I was wondering if it would bve possible to show some implementation examples. Like lfo´s, sequencers, vco´s that could make use of synapse´s cv capabilities. Many thanks

icnagy commented 6 years ago

Hi Thopa,

please see #5 and #6 examples. Hope it helps!

thopa commented 6 years ago

Hi! thank you so much for you examples, now everything is much clear. I was wondering how it would be possible to use the Ardcore Sketches with Synpase, since the ardcore also has 2 inputs and two outs puts (2 digital) and one dac. I see it would be great to do an impletentation of these sketches with synapse! Do you think you could crack this one up? Once i learn how you assign the variables and the dac i could implement (or try to) in other sketches: Here is on simple that divides the incoming clock. We could use gate in as source clock and output the divisions on gate outs A and B.

AC05_ClockDivide.ino.zip

Again thanks for your time and feedback, much appreciated!

icnagy commented 6 years ago

I can certainly give it a go!

thopa commented 6 years ago

Ignacy that would be awsome! I downloaded the synapse implementation and also the I/O dependencies. Literally I would like to be able to name the synapse ports as variables, so it would be "easier" to implement in the ardcore sketches which are great for eurorack! Something like bool gateout1 = Synapse::GateChannel::A bool gate out2 = Synapse::GateChannel::B bool cv out = Synapse::CVChannel::A bools cv2 out = Synapse::CVChannel::B

And the same with the input ports. Was trying last night but i was getting all kind of errors inside Arduino.

icnagy commented 6 years ago

Hi Thopa,

I'm afraid it's not that simple in this case. Please see #7. (I haven't got the shield with me at the moment, so I couldn't test it, but should be ok. I can confirm whether it works tonight.)

thopa commented 6 years ago

Wow you are on fire Ignacy, im at work but havwe been looking at you implementation in the code and i think it would work! Do you have any idea how to use the DAC on the Synapse board on the Ardcore sketches? This is the start template: ac01_template.zip AC07_sequencer.zip

I think the problem is that the Synapse board used a 12 bit dac and the original ardcores use 8 bit, but this could be solved with:

you need to add to the beggining of any sketch using the DAC,

include

include

DAC_MCP49xx dac(DAC_MCP49xx::MCP4921, 10); also you need to add the following code at the end of the setup() so the DAC is properlly initialized: dac.setBuffer(true); // Set FALSE for 5V vref. dac.setGain(1); // "1" for 5V vref. "2" for 2.5V vref. dac.setPortWrite(true); and finally replace the dacOutput() and dacOutputfast() to be something like: void dacOutput(long v) { dac.outputA(v); }

That examples is for using the ardcore with a MCP49 DAC, the synpase uses a MCP4922E SPI DAC which is quite similar, so following those guidelines it might work!!!

Ps: Im in debt with you!!! If you ever come down to Madrid let me know, tapas are on me!! Many many thanks!!!

icnagy commented 6 years ago

I think the DAC is used as the CV outputs.

There isn't any extra setup necessary, it's all included in the SynapseShield.begin();. In case needed, you can set the output resolution individually for both channels:

void setup()
{
...
  SynapseShield.begin();

  SynapseShield.setCVRange(
    Synapse::CVChannel::A,
    Synapse::Range::ZeroToTenVolts
  );

  SynapseShield.setCVRange(
    Synapse::CVChannel::B,
    Synapse::Range::MinusFiveToFiveVolts
  );
 ...
}

Than you just write any 12 bit value to the channel:

void loop() {
...
    SynapseShield.writeCV(Synapse::CVChannel::A, 4095);
    SynapseShield.writeCV(Synapse::CVChannel::B, 0);
...
}

In order to make musical scales, you'd have to know what 4095 means in terms of output voltage. Let's assume you set output channel A to 0-10 volts, we know that the DAC has a 12-bit resolution, so the maximum value it can present on it's output is

2^12 - 1 = 4095

So, when you write the value 4095 to the output channel A, you're instructing the DAC to output 10Volts. Writing 0 means 0 Volt in this setup, 2048 is +5Volts. (With that said, I think some of my examples are wrong, as they treat 4095 as being +5V...) For channel B with MinusFiveToFiveVolts config 0 means -5 Volts and 4095 means +5Volts.

So to get to a musical scale:

Value Volts Notes
4095 10V ~ 10 Octaves
4095 / 10 1V ~ 1 Octave
(4095 / 10) / 12 0.083V ~ 1 half note

So:

34.125 = 1 half note

Hope that makes sense?

icnagy commented 6 years ago

In the meantime #8 the Euclidian Rhythm example, with CV controlled rotate and added reset input via gate in B.

thopa commented 6 years ago

I dont know, im starting to think my ics are not correct. Im using a cd74h4053E instead of the 4053N stated. Might be culprit of all the problems :(

icnagy commented 6 years ago

Don't worry, I have the same one, I think they mean the same thing. Sent you a PM to sort this out.

shaduzlabs commented 6 years ago

I'm closing this issue, @icnagy provided a few (very useful) examples!