I'm trying to hook a SCP1000 from SparkFun up to my Sanguino. I'm using logic level converters from SparkFun because of the different voltages. I have the SCP1000 hooked up to a 3.3V power supply, which also feeds the low side of the converters. The high side draws its 5V power from the Sanguino. I've verified I'm getting the correct voltages at the correct points, and I've checked continuity between the Sanguino pins and the converters, and the SCP1000 breakout and the converters. I'm using the code from this post - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213217330/5#5, changing the pin #s to reflect the Sanguino.
But it doesn't work. How can I go about troubleshooting this? I'm not 1100% sure about my hookups. For example, I've taken Sanguino pin 5, marked MOSI, defined it as an output as per the code, and hooked it to an 5V input on the converter. The corresponding 3.3V output is hooked to MOSI on the SCP1000 breakout. So we have MOSI -> MOSI, and MISO -> MISO. Is that right, or seeing as it's serial should they be inverted? And other than that, what else can I try to get it working?
MOSI to MOSI and MISO to MISO is correct. MISO is "master in slave out", so MISO on the master side is an input, and MISO on the slave side is the corresponding output.
From the arduino side, MOSI, SS, and SCK are outputs. MISO is an input. Your level translator will need to be configured accordingly.
Thanks! I'm at work so can't check it out right now, but I'm pretty sure I've hooked it up correctly then. I'll do the Blink and Button tests on the low voltage side of the level converter to make sure it's working correctly. I should at least be able to get those working! Then I'll move on to the SCP1000 I guess.
One other thing, I have a 3.3V supply with seperate ground to the 5V from the Sanguino. Should I connect the grounds as a common ground or leave them separate?
OK, I just checked on SparkFun and it seems as though the level converter does have a common ground anyway. I'll check more closely tonight. I had briefly connected the grounds on my breadboard as one of my steps, but it was late and I couldn't tell you what the other hookups were at the time.
OK, I think I've found the problem, but I certainly don't know the cause. Although I'm supplying the LV side with 3.3V I'm only getting 2.5V on the LV outputs.
I'm a little fuzzy since it's been a while, but I vaguely remember that, of the two channels on those things (inputs vs outputs) one is a simple voltage divider with two equal resistors that is not even connected to the low side power supply. (you can check the schematic on Sparkfun's site)
So if your high side is 5V, 2.5V is a normal value on the other side.
If 3.3V is critical, you should note that the other channel (the one that is not a voltage divider but has a power component of some sort) is actually bi-directional and can be used as both input or output. This is handy when you have a line that needs to be used both ways, like in I2C.
So the Sparkfun description is at best sparse and at worst misleading... but at least half the gizmo is really useful and the other half gives you some space-saving voltage dividers for the bread-board stage.
The SCP1000 dtashet is sparse, but I would guess that a 2.5V input would be enough to trigger a logic high. The ATmega, for example, specifies that 0.7*Vcc is a logic high; a 3.3V ATmega would be satisfied with a 2.31V input as high.
Another gotcha with SPI is the fact that there are two parameters, clock polarity and clock phase, that determine which of 4 modes you are in. Different devices can use different modes. There are also speed parameters, etc. Some useful SPI info can be found in this tutorial.
Thanks guys! I was wondering if 2.5V was simply the divided HV side, but I seem to have found another problem, (or if 2.5V is sufficient to run the SCP1000 the only problem), in that the TX lines are always high regardless of connection, (even with no wires to them they're high!) So maybe this is the real problem I'm having?
Another question that sprang to mind is about SCK. I've connected to MOSI, MISO and SCK on the ATmega, but what actually tells the SCK pin it's a clock and not a simple digital pin? All the code does it set this pin as an output. No other reference is made to it throughout the code. This is my first stab at SPI, so I'm not familiar with how it's supposed to work.
OK, scrub that last paragraph, I'm reading the SPI tutorial now!
the TX lines are always high regardless of connection, (even with no wires to them they're high!) So maybe this is the real problem I'm having?
Write a simple sketch that makes them all low (or makes them cycle at a low rate, like 1Hz or so) and watch what happens on the output side of the translator.
I confirmed with SparkFun that the RX pins are just HV/2, and by putting a 2.2K resistor between TX and GND to pull it low seems to have worked, as far as the converter goes. I still can't get any readings from the SCP1000 though.
Can someone explain exactly what the last two bits which set the clock speed should be? I'm trying to go through the Amtel data sheet now.
OK, I think I've got the clock set right. f/32 - SPR1 = 1, SPR2 = 0, SPIX2 = 1 -gives 500KHz with f at 16MHz.
Still not working. >:(
How much do oscilloscopes cost and how would I use it? It might be better just to get an Arduino Pro Mini from SparkFun that runs at a native 3.3V. I don't think I have anything that needs 5V for this project.
It might be better just to get an Arduino Pro Mini from SparkFun that runs at a native 3.3V
Certainly cheaper than an oscilloscope, and 3.3V really simplifies things for certain sensors.
That said, there are several good and free software oscilloscope that use the sound card of your computer to capture the signal. The main downsides are that your are limited to lower frequencies (audio-range by definition) and that, at least on most laptops, the inputs are mono, not stereo, so you only get one channel... but since it's free, worth a try.
Don't forget to limit the voltage of your input to the sound card to 1V!
Actually, if you have issues with a protocol like SPI or I2C or some such, a logic analyzer is the way to go, rather than an oscilloscope, since it will do the low level interpretation of the protocol for you and it's easier to see if there are differences between what you think you are saying and what you really are saying.
Like using a phrase book in a bar in a foreign country, you may be insulting the poor node's mother or something.
I haven't gotten one (yet) but this one seems well reviewed.
I wasn't really serious about the oscilloscope, at least not at first. I didn't want the cost of this project to skyrocket, but the more I get into this microcontroller stuff, the more hooked I become. I'm a complete novice when it comes to electronics, although I can understand it pretty well when it's explained to me. I like to fix things that I can see are broken, but I can't do that in this case. I may have fried the chip when I soldered on the header pins, but have no way of knowing.
So if I continue with further projects, which I would like to do, then an oscilloscope would be a handy addition. I've seen logic analyzers and was thinking that might be a better option. But how about something like this oscilloscope instead - http://www.dynoninstruments.com/products_s2x100.php. In your opinion, for someone starting out, would a logic analyzer be better, or would an oscilloscope offer more useful capability? I can't decide, based on the type of signal I'm most likely to encounter being digital. Can an oscilloscope do logic analysis, but just on fewer, (only 2) channels? Although I've just checked out that link you've posted, and it looks pretty tempting.
Oh, and I ordered my 3.3V Arduino on the basis that when I put this project in its own box, and off the breadboard, I'll need one anyway so that I can work on the next project.
Well, for someone starting who should happen to have a sound card with stereo input, I'd recommend putting together a little input stage to bring 5V signals back down to 1V and use a software oscilloscope on the computer.
That should cover a lot of needs and detect simple mistakes like unconnected lines, biases, wrong levels, etc... with ease. It would also be great to look at analog signals from sensors and such to determine how to connect an Arduino to them.
Beyond that, you start spending money and it should to fit your budget and needs. I'm sorely tempted to get a good oscilloscope and a good logic analyzer but have yet to have hit something I couldn't solve by trial and error... mostly by luck, I suspect.
Not the definitive answer, but seriously, give that a try first. Even a mono signal software oscilloscope can be a life-saver.
I would strongly recommend you get an oscilloscope before you get a logic analyser.
While logic analysers are good they are mainly used for debugging memory / address bus type problems that require you to look at lots of simultaneous inputs and trigger on some arbitrary combination of them. They can only tell you a signal is not at the correct level at the correct time. A scope can show you where it is, that is has it never left zero volts, is it on it's way up but haven't reached there yet, is there ringing on the signal and so on.