Show Posts
Pages: 1 2 3 [4] 5 6 ... 48
46  Using Arduino / Networking, Protocols, and Devices / Re: SD card SPI conflict on: July 27, 2013, 07:28:26 am
Hi Nick,

Thank you so much for your reply. I chose 100 Ohms for the series terminator based on the characteristic impedance that a 2.5" long 24mil-wide trace produces. All the other SPI lines were so short that they were going to be OK either way (i.e. less than 2"). Paul S. also recommended a 100 Ohm resistor for the CLK signal the Teensy 3 is producing for the MCP3911 to reduce potential for EMI issues.

Are conflicts between SD cards and other devices on an SPI bus so common that the cards need to be segregated? In the current incarnation, the idea was to log relevant data once a second to the SD card. The SPI bus is running at 8MHz (the maximum, allowed, it appears). The teensy may or may not be able to bit-bang at up to 12MHz because of the clock-divs that the teensy offers (the maximum frequency that a PWM pin can produce is 12MHz, as best as I can tell).

I am really reluctant to learn / implement how to bit bang, but there doesn't appear to be an alternative. I wonder why the SD card is answering / interfering when its CS-pin is held high by the MCU and features a (belts and suspenders) pull-up (10K) as well.
47  Using Arduino / Networking, Protocols, and Devices / Re: RS485 with attiny45/85 on: July 27, 2013, 05:28:46 am
All depends on your application. However, if the aim is to reliably and easily transfer data serially (or via rs485) then easy transfer is a huge time saver. 
48  Using Arduino / Networking, Protocols, and Devices / [SOLVED] SD card SPI conflict on: July 27, 2013, 12:06:45 am
Hi guys and gals,

I have a teensy 3 on hand here interfaced on a board with a SPI bus that has a MCP3911 AFE and a SDHC card. The whole system runs at 3.3V so there are no level translators in use. Power is provided by a stable MCP1702 power supply instead of relying on the voltage regulator inside the teensy chip (disabled). Anyhow, the system is working just fine with just the MCP3911 on the SPI bus. Speaking of which, the bus is running at 8MHz and in Mode0, with MSBFirst.

 Both CS lines feature pull-up resistors and behave as one would expect. However, insert a SDHC card and the SPI bus comes to a grinding halt. The Saleae Logic 8 reports a mismatch and the screen indicates no SCK action.The bus doesn't show any MISO action either, just MOSI and CS. My electrical connections should be good since I have used this same card and holder successfully in previous designs and my computer can read and write fine to it. So, I have a couple of questions that I hope folk can answer here.

For one, would a series terminator on the SCK line potentially cause this problem? I'm using a 100 Ohm resistor because the distance from the SCK line (24 mil wide) is much greater than for the other pins on the SPI bus (which do not feature a similar 0805-based resistor).

Is there anything different when it comes to SD cards like maximum SPI bus speeds that one should stay under (it's operating at 8MHz presently). Is SPI0 the proper mode?

Should I consider putting these devices on separate SPI buses (not just use CS-pins) by bitbanging the ADC output?
49  Using Arduino / Networking, Protocols, and Devices / Re: RS485 with attiny45/85 on: July 26, 2013, 11:50:09 pm
In order to make the RS485 transmissions as painless as possible, I highly recommend Bill Porters EasyTransfer library.
50  Community / Bar Sport / Re: Your latest purchase on: July 16, 2013, 12:36:52 pm
The platters are nice too. They'd make nice Tesla Turbine disks.

Or frisbees. In high school we had a Vax 750/11 with a RL02 removable hard disk drive, among other, refrigerator-sized attachments. These RL02 discs crashed often, and we'd scavenge the insides of the carrier for the platters and play frisbee with them. At about 14" across and heavy, good palm protection was a must, as was good aim. Otherwise, you'd be at risk of a 'oddjob' re-enactment.
51  Using Arduino / Networking, Protocols, and Devices / Re: SPI communication failure... anything obvious with the code? on: July 08, 2013, 05:57:49 pm
Thank you!

So it's likely I destroyed the Mcp3911 by using the continuity beeper mode on my fluke 87 DMM. Now I know the current the DMM produces in that mode is high enough to damage the mcp3911.  Also found out that the teensy 3 offers a simple way to put out a 12MHz Osc signal for the mcp3911. So I will use that instead of the crystal to drive the mcp3911.

Live and learn. Thanks again for your help. The code has been updated per your suggestion.
52  Using Arduino / Project Guidance / Using a Oscillator vs. Crystal with Caps on: July 08, 2013, 10:30:37 am
Hi, I wonder if anyone can enlighten me regarding the relative merit of using a crystal with load capacitors vs. an actively-driven oscillator like this Abracon. Is this a pure cost decision?

I really appreciated the ease with which some resonators could be used with Atmegas and wonder if oscillators like the one above (plus a de-coupling capacitor) might also make my life easier (in return for a small additional cost and a VDD line to the oscillator). Thoughts?
53  Using Arduino / Networking, Protocols, and Devices / Re: SPI communication failure... anything obvious with the code? on: July 08, 2013, 10:25:18 am
So, rechecked the data sheets on the respective devices and it appears I had MISO and MOSI swapped. Fixed that, but still no go.

Next, I am going to reduce the speed of the external oscillator to see if that is the issue.

FWIW, the datasheet expectations seem to be met per your output. I am trying to modify register 0D (13 decimal). The MCP spec requires the command byte to start with two zeros (unless you use a different version of the chip), followed by the five bits of the register address you want to modify, and then the read/write bit. Thus, in order to construct the write command byte, I start off by left shifting the desired register by one bit (doubling its value) and then applying a mask to turn the LSB to zero.

If you have a look at the bottom of p. 48 on the MCP3911 datasheet, you can see the reset command being illustrated just as I described and exactly like the MOSI output you so graciously created for me. Thank you again for modeling it on your Arduino and confirming the results.

Yet my MC3911 still returns nothing but zeros when I try and read any responses. Argh.
54  Using Arduino / Networking, Protocols, and Devices / Re: SPI communication failure... anything obvious with the code? on: July 08, 2013, 06:21:42 am

Thank you so much for that advice! I added the suggested digitalWrite line but it had no effect - the program keeps looping without any change in behavior.

So unless there is something blindingly obvious, I will shift over to a hardware diagnostic. FWIW, I have a saleae logic 8 on order, as the logic analyzer built into the QuantAsylum mixed scope is just too unintuitive to use for me (I obviously acknowledge that others may love it and find it super easy to work with).

One of the things I will send up to MCP for advice is the use of the clock crystal -maybe I am pushing it - but I didn't think it would have any impact on the SPI interface.
55  Using Arduino / Networking, Protocols, and Devices / [SOLVED] SPI communication failure... anything obvious with the code? on: July 07, 2013, 11:54:33 pm
Hi everyone,

I am currently trying to get my Teensy 3 and a MCP3911 to communicate via SPI (code below). Unfortunately, I am getting nowhere. Instead of getting the desired response (i.e. an acknowledgement that the right register (0x0D) has been modified to put the ADCs into reset mode), I get nothing but the following:.

Command Register Received: 1101 - Command Received: 11000000
Write Command Byte Sent: 11010
Read Command Byte Used: 11011
Error for register: 1101 - Command Sent: 11000000 - Response Received: 0

Other registers have responded with nothing but 1's.

For those of you well versed in the art of SPI, is there something obvious that I have missed? The bare electrical connections appear to be good, so I feel like I am running out of options... Any help is appreciated and thanks in advance. Constantin

#include "SPI.h"
const uint8_t MCP3911_CS = 9; // Teensy SPI CS1 = MCP3911
const uint8_t SD_Card_CS = 10; // Teensy CS0 = SD Card
const uint8_t MCP3911_DR = 2; //Data Ready Signal for MCP3911

const uint8_t LED = 13; //LED on Teensy

void setup() {

  //SPI Bus setup
  pinMode (MCP3911_CS, OUTPUT); // MCP3911
  pinMode (SD_Card_CS, OUTPUT); // SD Card
  pinMode (MCP3911_DR, INPUT); //Data Ready Pin on MCP3911
  SPI.setClockDivider(SPI_CLOCK_DIV8); //i.e. 6MHz on a Teensy running at 48MHz.
  //Setup Serial Comms
  pinMode(LED,OUTPUT);  //enable blinking LED    

void loop()
  bool led=1;
  for (int i=0;i<2;i++) {
    led = !led;
  Reset_ADC(); //Setup the MCP3911

uint8_t Write_MCP3911_Register (uint8_t MCP3911_Register_Address, uint8_t Command) {
  Serial.print("Command Register Received: ");
  Serial.print(" - Command Received: ");

  MCP3911_Register_Address = (MCP3911_Register_Address<<1) & B00111110;
  //right shift address one digit
  // and ensure last digit is a zero for write command
  digitalWrite(MCP3911_CS, LOW);
  SPI.transfer(MCP3911_Register_Address); // send address with write command to MCP3911
  SPI.transfer(Command); //now send payload
  digitalWrite(MCP3911_CS, HIGH); // deselect the CS pin.

  Serial.print("Write Command Byte Sent: ");
  Serial.println(MCP3911_Register_Address,BIN); // verify what command was sent (i.e. address and write bit = 0)

  //Now Verify all went well
  MCP3911_Register_Address += 1; //Turn on Read Operation by toggling last bit on
  Serial.print(" Read Command Byte Used: ");
  Serial.print(MCP3911_Register_Address,BIN); //show command used
  digitalWrite(MCP3911_CS, LOW); //take CS low to initiate SPI  
  SPI.transfer(MCP3911_Register_Address); // send address with read command to MCP3911
  uint8_t Response = SPI.transfer(0x0); //read one response
  digitalWrite(MCP3911_CS, HIGH); //take CS pin back high again to end SPI transmission

  //now verify that the register content matches the command sent. If so, have the function return value of one,
  //otherwise, alert the user that something is amiss.
  if (Response == Command)  return 1;
   Serial.print("Error for register: ");
    Serial.print(" - Command Sent: ");
    Serial.print(" - Response Received: ");
    return 0;

uint8_t Read_MCP3911_Register (uint8_t MCP3911_Register_Address) {
  Serial.print("Desired Register Address: ");

  MCP3911_Register_Address = (MCP3911_Register_Address<<1) & B00111110; //right shift address one digit and mask first two bits and last
  MCP3911_Register_Address +=1; // add one to toggle read bit
  Serial.print(" - Read Command Sent: ");
  digitalWrite(MCP3911_CS, LOW);
  SPI.transfer(MCP3911_Register_Address); // send address with read command to MCP3911
  uint8_t Response = SPI.transfer(0x0);
  digitalWrite(MCP3911_CS, HIGH);
  Serial.print(" - Response Received: ");
  return Response;

void Reset_ADC()
 // Puts ADC into Reset Mode, i.e. stops ADC conversions until setup is complete.
   bit 7:6 RESET<1:0>: Reset mode setting for ADCs
   11 = Both CH0 and CH1 ADC are in reset mode
   10 = CH1 ADC in reset mode
   01 = CH0 ADC in reset mode
   *00 = Neither ADC in reset mode(default)
   bit5:4 SHUTDOWN<1:0>: Shutdown mode setting for ADCs
   11 = Both CH0 and CH1 ADC in Shutdown
   10 = CH1 ADC in Shutdown
   01 = CH0 ADC in Shutdown
   *00 = Neither Channel in Shutdown(default)
   bit 3: Not implemented, read as 0
   bit 2: VREFEXT Internal Voltage Reference Shutdown Control
   1 = Internal Voltage Reference Disabled
   *0 = Internal Voltage Reference Enabled (Default)
   bit 1: CLKEXT Internal Clock selection bits
   1 = External clock drive by MCU on OSC1 pin (crystal oscillator disabled, no internal power consumption) (Default)
   *0 = Crystal oscillator is enabled. A crystal must be placed between OSC1 and OSC2 pins.
   bit 0: Not implemented, read as 0

  Write_MCP3911_Register (0x0D, B11000000);
56  Using Arduino / General Electronics / Re: Need help with a power supply... on: July 06, 2013, 12:39:38 am
...I suspect the cost of a new hub would be less than all that (and much less risky). So, how did you know that only a new hub was probably needed?      

I did it on the basis of the weather station behaving as it should, i.e. multiple flashes of the diagnostic LED in the right sequence made me believe the unit was OK, and that the receiver was at fault. So I bought a new SL-HUB on ebay for $29 and tried it out. Worked for about a week and then the unit on the roof started making error codes that are undocumented. So I gave up and replaced the SLW10 with new wireless version. If it wasn't the voltage that killed the unit, nearby lightning may have done it.

However, based on my trace of the unit, my best guess is that the power supply on the unit inside the controller cannot handle my local conditions. My primary voltage is always around 125VAC, and by the time it lands inside the controller, the nominal 24VACrms turns into 27VACrms.While the rest of the controller seems to handle that OK, the plug in module with its minimal power supply does not seem to. Interestingly, CUI now offers a tiny drop-in replacement for 7805's with a very wide input voltage range. Admittedly, they are not cheap (about $8), but it may be my best bet to get a power supply that can handle the hazards of my local conditions - up to 72V with the 78w-500.
57  Using Arduino / Sensors / Re: MCP3901 looks like a neat chip... Anyone have experience with it? on: July 01, 2013, 03:07:40 pm
It uses SPI, which I dislike
Why? Is it due to SPI being up to 20 times faster than I2C?
Or you don't like giving up 2 pins for all that speed?

Neither. Unlike I2C, I have never ever had any good luck dealing with SPI devices other than memory cards. Presumably, a lot has to do with the devices in question, my inability to decipher the relevant datasheets, and my inexperience. Perhaps I2C is simply more tolerant for hamfisted beginners like myself.
58  Using Arduino / General Electronics / Re: Dealing with Audio Interference on: June 04, 2013, 08:58:49 pm
Can you have access to a scope?
It could be a ripple problem or perhaps a bad linear VCC. A scope will give you your answer

No linear regulator - the switch-mode power supply doesn't feature one. I checked the signal out on a scope and saw a bit of ripple. Dimension Engineering suggested retrofitting a 1000uF capacitor, which seems somewhat counterintuitive - I would have thought an inline inductor would make more sense?
59  Using Arduino / General Electronics / Dealing with Audio Interference on: June 04, 2013, 02:08:21 pm
Some time ago, I posted here a diagram / pics of a UPS kit that powers the home phone base station and charges 2 iPhones at 1A thanks to the detective work at Adafruit. Yesterday, I finally got around to assembling the last bit, i.e. building a connector between the board and the base station. I've never had to solder connectors before, so this was a new experience for me. Anyhow, it all worked eventually, with one quirk: Noise!

Specifically, if the base station is powered using the standard wall-wart (looks and feels like a linear power supply), the voice channels are clear as a bell. Power the base station using my rig and there is a lot of background noise - basically static. I presume this is EMI entering via the power supply as the noise does not change as a function of distance, etc. of the base station to the power supply.

What would be your suggestion on how to best fix this? I have a number of old external clamp-style ferrite cores lying around, so my first inclination is to add one, wrap the wires around it a couple of times and see what happens. Similarly, I'm also considering retrofitting a capacitor on the output side, even if Dimension Engineering claims that "It has integrated decoupling capacitors, so external capacitors are not generally necessary". If you'd add a decoupling capacitor, I assume you'd want a small 0.1uF ceramic unit to hold in the noise?
60  Using Arduino / General Electronics / Re: Need help with a power supply... on: May 25, 2013, 11:57:11 pm
The hand soldered diode (i.e. not the SMD diode D1 that is part of the power supply circuit) appears to run from a signal line on the pin header (which is how the SL-HUB interfaces with the irrigation controller to the 5VDC pin on the LM7805. Given the crude solder job, the lack of a printed circuit, header holes, etc., and the lack of any kind of designated spot for the thing, my guess is that this diode is something they figured out they needed after a bazillion boards had been already printed. My guess regarding its intended duty would be signal protection, i.e. it prevents signals from exceeding ~5VDC.
Pages: 1 2 3 [4] 5 6 ... 48