FAQ & Terms of UseFAQ & Terms Of Use   Wiggler RadioMW Radio   Muff Wiggler TwitterTwitter   Support the site @ PatreonPatreon 
 SearchSearch   RegisterSign up   Log inLog in 

Stripped down, pure C programming (Ardcore style)
MUFF WIGGLER Forum Index -> nw2s  
Author Stripped down, pure C programming (Ardcore style)
I'm not super good with C# but I found the C programming for the Ardcore very straight forward and fun. It allowed me to just come up with things on the go, which I feel is harder than using the framework for the nw2s.

Don't get me wrong, the framework is great and it really turns the module into a true product, but I'd love to be able to do what I did for the Ardcore but with all these nice ins and outs.

So far I've come up with this one: no

and another member has made this one:

But so far, none of us has cracked the code for accessing the analog ins or analog outs. This can't be that hard!

Please, please, please someone help us get this working so we can do 1v/oct input control and send out notes! I just sit and stare at my nw2s right now. waah
Magnus and I have been working through some stuff offline and I asked him to bring it up here in case some others of you are also interested in a simplified API.

I think some of the complication may be that since the 'b hardware is just a lot more complicated than the ardcore, for me, it's easier to abstract that away which is what I've done with the API (and even more so with the SDFirmware).

With getting the 1.0 firmware out, getting the 'io module ready, work obligations, plus vacation, I was a little slow to respond, so hopefully we can start a conversation here that's tracked a little easier and some others can pitch in if they see something interesting.

So maybe the first question is how to do some 1V/oct analog in to pitched CV out? (and Magnus is avoiding using the framework as-is, so that's one complication...)

Some things to consider when reading the analog inputs on the 'b:

1. They are 12 bit (0-4096) rather than 8 bit on the Ardcore
2. They are inverted! Yes, my op amps are inverting so 4096 = -5V, 2048 = 0V, and 0 = +5V (or thereabouts)
3. If you are patching in to the analog input jacks, always turn the pots to 100% - they are configured as trimmers on the analog in. This allows you to technically have greater than 5V inputs.

I'll write some more later. Catching up and wanted to follow up while I am here.

...Also, setting up a b-minimal code repo. I'll limit this to C-only, but will provide basic abstraction of the SPI protocol, port initialization, and while I can't promise it'll be exactly the same as Ardcore, I could provide something a bit less framework-driven. (empty now... but will start getting some stuff up there)

Wonderful! My eyes are glued to that repo.
Any progress here? We have the digital outs working but the rest?

scottwilson wrote:

2. They are inverted! Yes, my op amps are inverting so 4096 = -5V, 2048 = 0V, and 0 = +5V (or thereabouts)

This one I tackled by doing a subtraction:

int bpmSubtraction = 400 - (constrain(analogRead(0), 0, 399));

but maybe there are better ways?

What about the analogIns and Outs?
No progress, but to be fair, I haven't done any coding for the full framework either. The time I've had has been spent on the io module, but that's been limited too. Day job plus a new kindergardener this year is demanding most of my attention. This should be getting better soon tho.

I don't use constrain at all - I thought it was just a function that sets the upper and lower limit - but the way you're using it would imply that it does some scaling as well. That looks fine for that analog inputs.

For the analog outputs, since it's on an SPI bus, will take a little more work. To do it in C mode (as opposed C++), then it'll just need an analogWrite() method that is stateless and can manage the SPI protocol to be able to write the output voltage to that output. It'll be able to look like the Arduino method, but under the covers will need to do a bit more.

That and a list of constants so you don't have to memorize pin numbers would be my fist steps.

I have not managed to start from fresh but there has been some progress in this repo:

The only thing I can't seem to find a way to control are the "digital in" jacks. The switches work but I can't send in a trig or gate and get them to react.

Scott, is there an example program where you trigger the digital ins via the jacks?
Left is momentary on
Center is always off
Right is latched to the value of the jack (which is normalled to +5V)

This means that if you want to read the jacks, you have to flip the switch to the right. Possibly not the most intutive, but I did this so that momentary would always work, even if there was something plugged into the jack.

Ah! Thank you. I'll try that.
Similar thing with the analog reads - The jacks go through the pots so that you can use the pot as an attenuator. If you want to read analog values unattenuated, you need to turn the pots to 100%.

I have one of these puppies on the way, and though this thread is a bit old, I wanted to mention that I'm a coder and would prefer C/C++ or something procedural to a declarative framework, if only because I like DSP (having lots of fun working with audio in Cinder these days) and coding my own logic.

I also anticipate trying to make a super-disting with my mod as I always need the same few functions - i'm sure this would be more feasible with "raw" code than the (very cool looking) declarative DSL.
Looking forward to hear what you do with it.

When we were considering this, it was in response to some requests for a lighter-weight framework that worked without C++ (so you could use C) - turned out to be quite a bit of work.

But to be clear there are two ways to work with the 'b framework. One of them is pure declarative JSON format for non-programmers.

The other allows you to write in either Arduino C with just a bit of C++, keeping most of the logic within the ino file (a la Ardcore) - or you can go full C++ mode and have a minimal ino file with all of the logic in class files, abstracting away the difficult parts and making it easier to reuse bits an pieces.

It's up to you. There are some good examples of both online now - between Alwaysnew who has his own repo or my examples and even some from scannerdarkly who is contributing to the 'b repo.

Let me know if you have any questions!

MUFF WIGGLER Forum Index -> nw2s  
Page 1 of 1
Powered by phpBB © phpBB Group