Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Communication with a programmable electronic load. on: December 17, 2012, 12:29:21 am
I'm confused about which communication protocol to use, SPI, I2C or just the shiftOut commnad.
I have a programmable electronic load, Datel DTL2A-LC
http://www.alldatasheet.com/datasheet-pdf/pdf/194101/ETC2/DTL2A-LC.html
The communication states "CMOS/TTL compatible, serial input current sink"

The DAC needs to get a 12 bit value to set the load current, from 1 to 4096.

The device has 4 pins for input:
Latch Data - LD
Serial Data In - SDI
Clock - CLK
Control Strobe - CS

I tried following the instructions in the datasheet; however, it specifies that the instructions are for C Language. I translated to the Arduino, see my sample below.
I have tried using the shiftOut command with no success.

Code:
/*
 
 This sketch is designed to communicate with the ELTEST EL2A-LC programmable electronic load
 Communication with the EL2A-LC is with the shiftOut command
 Tested with Arduino Mega running IDE 1.0.1

 Created  December 16, 2012
 By Vitor2
  
 */
 
int latchPin = 8;  //Connected to pin 4 of Eltest
int clockPin = 12;  //Connected to pin 6 of Eltest
int dataPin = 11;  //Connected to pin 5 of Eltest
int strobePin = 7;  //Connected to pin 7 of Eltest

void setup() {
  //set pins to output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(strobePin, OUTPUT);

    //I did not include sending the data in the loop because I only want to do it once.
    //This may not belong here.

    //Initialization
    digitalWrite(strobePin, HIGH);
    digitalWrite(latchPin, HIGH);
    digitalWrite(clockPin, HIGH);
    delay(10);
    digitalWrite(strobePin, LOW);
    delay(10);

    //Send one value between 0 and 4096 to the device
    //The value should be a 12 bit binary?
    shiftOut(dataPin, clockPin, MSBFIRST, 100);  //Value of 100 should be 0.488 Amps

    digitalWrite(strobePin, HIGH);
    digitalWrite(latchPin, HIGH);
    digitalWrite(latchPin, LOW);
    digitalWrite(latchPin, HIGH);
}

void loop() {

  }
2  Using Arduino / Programming Questions / Re: AD conversion adjustments. Look up table? on: August 03, 2012, 01:12:34 pm
Correct, that is what I have been asking for help.

I need a correction factor, adjustment, whatever you want to call it, for each one of the channels.
When the Arduino loops 12 times to get the reading from each of the channels I need to multiply the reading from the ADC by the multiplier (adjustment factor, correction, call it what you may) to get the actual voltage for each of the channel readings.

I need to store and recall each one of those values and call them accordingly.
3  Using Arduino / Programming Questions / Re: AD conversion adjustments. Look up table? on: August 03, 2012, 10:17:04 am
The 10mA load stabilizes the readings, it removes superficial charge from the batteries I'm reading.
There is an optoisolator between the ADC and the Arduino, also an isolated DC-DC. Now we are getting off the topic here.

The ADC converter is extremely accurate, the readings are very consistent, I only start seeing "jumping" on the third decimal.

The error is induced by the slight difference in the resistors used in the voltage divider, hence the need for the correction factor.
4  Using Arduino / Programming Questions / Re: AD conversion adjustments. Look up table? on: August 03, 2012, 03:01:56 am
Reason? yes.
I'm reading voltages in 20 volts increments. Chan1 up to 20V, Chan 2 up to 40V, Chan3 up to 60V... Chan10 up to 200VDC,
The voltage dividers scale it down to about 4.8 volts if the highest voltage ever reaches 200, not likely though, usually 185 is the highest and I left a little room in the divider also. So, a 10mA current will disipate 1.85 watts in Channel 10. I use two 1watt resistors in those channels.

I apologize if this is a beginner know how.
The difference in readings is not linear, two of the channels are spot on the readings, some are over and some are under.
The correction factor is what I describe as a multiplier. I need one for each channel.

Thak you for your time.
5  Using Arduino / Programming Questions / AD conversion adjustments. Look up table? on: August 03, 2012, 02:43:34 am
I have a MAX1238, 12 channel, 12 bit, ADC that I use to read 10 voltages.
I use 10 voltage dividers, and even using 1% resistors, there are slight variations in the voltage out of the dividers.
By the time I multiply the 12 bit value, the error magnifies.
I thought about a multiturn pot for fine adjustment to the voltage dividers, but 3 of the voltage dividers disipate 1 to 1.7 watts.

Currently, from the lowest to the highest readings, the difference is about 6% using the same multiplier to all 10 channels.
Ideally, I would like to have 1% difference.

I need to have 10 different multipliers, one for each channel to adjust to actual readings taken with a DVM.

What would be the best solution to store and recall those 10 values?
6  Using Arduino / Interfacing w/ Software on the Computer / Re: Create application to enter data, send to Arduino and receive and display data on: January 07, 2012, 04:05:45 pm
Thank you Paul.
Last night I found a simple sample online and got it going right away.
It is very promissing, I think it will be able to do what I need.
I'm surprised there is not a lot of talk about C# Express.
Do you know or recommend a site like Arduino for C# Forum support? I found a couple, but not very impressive, I also found some tutorials, but fairly simple.

Thank you again.
7  Using Arduino / Interfacing w/ Software on the Computer / Re: Create application to enter data, send to Arduino and receive and display data on: January 06, 2012, 11:00:44 pm
Thank you Paul for your comment and direction.
I have done extensive Visual Basic in MS Access and I'm familiar with the structure, I will take a look at C# Express.
8  Using Arduino / Interfacing w/ Software on the Computer / Create application to enter data, send to Arduino and receive and display data on: January 06, 2012, 02:09:59 pm
Information and suggestions needed.

I want to have a form (or application) in a PC where I can enter variables and then send them to Arduino and start the process. Variables such as delay, integers, file name to log to, etc.
As the process runs, I want to receive data from Arduino and display in the form (or application), I want to see. Time elapsed, voltages, temperature, amperage, file name.

I have the Arduino elements already working together, now I need to develop (create) the form that will communicate with Arduino.

I looked at Processing and so far I have not found an example to indicate I can use it to do what I want to do.
The form would have drop down menu to select information and boxes to enter data that needs to go to Arduino.
It needs buttons to start the process, pause, stop, etc.
It needs fields to display time and readings taking place in Arduino.
9  Using Arduino / Programming Questions / Help how to write to the buffer before sending data to SD card on: December 31, 2011, 07:56:16 pm
I use an Arduino Uno with the Adafruit Datalogger.
I read a 12-bit, 12 channel ADC, I convert to a float variable and then I send the data to the SD card one variable and one comma at a time. This is very slow.

I have searched for the code to store data in the buffer and writing the buffer data to the SD when it gets close to the buffer size of 512 Bytes. No luck finding the code.

I'm using the SD.h library.

Here's the portion of the code where I read the data, convert it to integer, float and then send to the SD card.

Code:
while(Wire.available())          // Check for data from slave, as long as there is data in the buffer, the slave will
                                    // be sending to the master 2 bytes at a time, sending the MSB first and LSB next

   {
     Adval_High = Wire.receive();   // Receive data from ADC, High-Byte, this is an 8-bit byte, the first four bits are 1111
     Adval_Low = Wire.receive();    // Receive data from ADC, Low-Byte
     Adval = word(Adval_High , Adval_Low);  // Combine the High-Byte and Low-Byte into a 16-bit integer
     Adval = Adval & 0x0FFF;    // Mask the 16-bit integer with Bitwise-AND and value B0000111111111111,
                                // this eliminates the first 4 unused bits (1111) of the High-Byte, creates the 12-bit value
     Adval = Adval - PrevAdval; // deduct the current reading the previous reading
     AINVolts = (Adval * 0.0012207); // convert the integer to Volts
   
     dataFile.print(AINVolts);
     dataFile.print(",");
     //Serial.print(AINVolts); //for debugging
     //Serial.print(",");  //for debugging
   
     PrevAdval = Adval + PrevAdval;     // assign the new reading to the previous reading variable
   }
    dataFile.println();
    //Serial.println(); //for debugging
    dataFile.close();
  } 
10  Using Arduino / Programming Questions / Re: Combine two bytes into one integer to get a 12-bit value. on: December 23, 2011, 03:29:34 pm
Thank you.
I had a mental block.
11  Using Arduino / Programming Questions / Combine two bytes into one integer to get a 12-bit value. on: December 23, 2011, 02:29:29 pm
Sounds easy and probably is; however, there is a kink to it.

I'm reading data from a 12-bit, 12 channel ADC, MAX1238. For now I'm only concentrating on one channel, AIN0, and the communication takes place over I2C.
http://datasheets.maxim-ic.com/en/ds/MAX1236-MAX1239M.pdf

This is the decription of the read cycle in the datasheet.
The result is transmitted in two bytes; first four bits of the first byte are high, then MSB through LSB are consecutively clocked out.
I have no idea why the engineers decided to make the unused bits high. It serves no purpose at all, or at least one I can understand.

When the AIN0 input is grounded I should get two bytes B00000000 and B00000000.
This is what I actually get B11110000 and B00000000. This is expected per the datasheet information.

I need to remove the first 4 bits from the highByte. This is where I'm stumped.
If I just shift them to the left with << 4, when I have a value in the highByte, the value gets distorted by the shift.
After eliminating the 4 bits, I need to combine the remaining 4 bits from the highByte and the 8 bits from the lowByte to give me the 12 bit value.

Any and all help is greatly appreciated.
12  Using Arduino / Sensors / Re: Recommendation needed, 12-16 channels 12-bit SPI interface ADC on: December 12, 2011, 11:09:22 pm
Thank you.
Interesting, I came across a MAXIM MAX1238 Evaluation Kit 12bit 12 Channel ADC yesterday on eBay and I purchased it.
I will be testing it and see how it works, the nice thing is that th evaluation board has built in resistors and capacitors, it looks like a low pass filter at each input, which will help me with a problem I'm having with too much electric noise in the readings I'm taking.
13  Using Arduino / Installation & Troubleshooting / Re: Arduino 1.0 upload issue on: December 09, 2011, 10:58:05 pm
I'm in worst shape. I'm not even getting out of the gate.
The new IDE is compiling an existing sketch and declaring it has a lot of errors.
This is what I get when trying to load the existing Examples/SD/CardSnfo


In file included from CardInfo.cpp:20:
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:18:22: error: WProgram.h: No such file or directory
In file included from D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:20,
                 from CardInfo.cpp:20:
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/utility/SdFat.h:286: error: conflicting return type specified for 'virtual void SdFile::write(uint8_t)'
D:\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
In file included from D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:21,
                 from CardInfo.cpp:20:
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/utility/SdFatUtil.h: In function 'void SerialPrint_P(const prog_char*)':
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/utility/SdFatUtil.h:58: error: 'Serial' was not declared in this scope
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/utility/SdFatUtil.h: In function 'void SerialPrintln_P(const prog_char*)':
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/utility/SdFatUtil.h:68: error: 'Serial' was not declared in this scope
In file included from CardInfo.cpp:20:
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h: At global scope:
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:26: error: expected class-name before '{' token
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:35: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:53: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:61: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:65: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:68: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:70: error: 'boolean' does not name a type
D:\Documents and Settings\Work\My Documents\Arduino\libraries\SDbu/SD.h:83: error: 'boolean' does not name a type

14  Using Arduino / Sensors / Recommendation needed, 12-16 channels 12-bit SPI interface ADC on: December 08, 2011, 03:37:47 pm
I'm looking for an ADC with a mininum of:
12 channels or two 8 channels
12-bit resolution
SPI communication, I2C may do; however, I'm already using SPI for the data logger.
Capable of reading 5V
Speed is not very important
DIP preferred but not a big deal

Have you used something along these lines? What would you recommend?
Pages: [1]