Propeller Flip with MCP3002 comms
ardillolambo
Posts: 11
in Propeller 1
Hi there,
New to the propeller world.
I got myself a Flip, want to add the capability to read analog inputs from a sensor, in this case a temperature sensor, using a MCP3002
I guess the comms will be SPI, so....
1) someone out there can point in the right direction how to program the Flip to "talk" to MCP 3200
2) how many MCP3200 can be talking to the flip?
3) MCP3208 can be used as well?
Thats it for now
Comments
Try These
Easy-peasy. I don't have an MCP3002, but I have used the MCP3202 (12-bit), so I made a copy and modified it for the 10-bit variant. I have used the MCP3208 many times. My friend John at jonyJib.com uses two of these in many of his products. You can share the SPI bus pins and use a chip select for each; five IOs will give you 16 analog channels. Note that if you want to use 5v for the ADC, put a 4.7K resistor between the DO pin of the ADC and the MISO connection to the Propeller.
If you wanted to read sixteen channels with the object you could create two copies like this:
You have to start them; I tend to do this in a method called setup():
Then, let's say your app wants to do single-ended readings of 16 channels; you could write a shell interface like this:
Of course, you should not take my word for anything, you should hook up a circuit and test it. Talk is cheap. Doing is valuable. Doing is better.
Have fun!
DigitalBob/JM
I appreciate your help and time but the propeller flip is mainly programmed in C++, because of that my application is being developed in c++. Don't know how to "translate" that to c++
Regards,
Not sure if you've already been down this road, but there's an ASM driver at GitHub that might be close to what you need ? : https://github.com/parallaxinc/propeller/tree/master/libraries/community/p1/All/ADC MCP3204 SPI Driver
If you're developing in C using FlexProp, I think you can include ASM libraries ? (hmm, Probably you could include SPIN also that way, and use Jon's example... you might have two possible solutions depending on the IDE you are working with).
Arh-- I see DigitalBob already posted much the same example in ASM. So seems you might need some help integrating that to your IDE.... What are you using ?
I'm using a propeller flip 32123 with an MCP3002 for know just to get familiar with it (thats what I have laying around) later on would like to use a MCP3204.
I found a library in SimpleIDE but I'm investigating now how can I add that library to my libraries folder to test.
I'd think if nothing else, SimpleIDE will look in the folder your code is in.
I've added some other ideas to your other thread : https://forums.parallax.com/discussion/174816/how-to-add-a-downloaded-library-to-my-library-folder-simpleide
No, the FLiP is not mainly programmed in C++, it is programmed in a variety of languages, including it's native language, Spin (which exposes everything about the Propeller architecture, hence is good to know, even if you choose to use C for your application ). I have translated thousands of lines of C to Spin, so the question becomes: What's stopping you from translating my simple Spin code to C (other than the very small effort required to do it)? It would be a fun exercise and get you closer to the P1.
Can't be bothered? Eric Smith's FlexProp is quite popular with C programmers and he has a mechanism that allows C programs to use Spin objects as libraries.
This works. I tested on a P1-powered (same as the FLiP) EFX-TEK HC-8 controller with an ADC-4 (MCP3204) add-on board) (I designed both boards for EFX-TEK).
This also works, demonstrating that with just a little effort, Spin can be translated to C (again, I'm using FlexProp because it seems to be the most popular among Propeller users who prefer C).
Thumbs-up for that.
Trying out and comparing the two IDEs for your own preference well recommended. SimpleIDE has it's quirks, not least because it hides away functionality in an attempt to simplify the coding process for a certain audience, whereas FlexProp is functionally open and accessible, especially more likely to appeal to an existing C coder.
The actively developed FlexProp in many ways is also more capable, compared to the many-years-old and end-of-development SimpleIDE project. Good to try both and choose what suits your style.