Jump to content

JStat60

Members
  • Content Count

    17
  • Joined

  • Last visited

  1. JStat60

    Noise in ADC

    That was a good suggestion @spirilis, I posted on the E2E site on the recommendation of the folks at Mouser. Had they not recommended this (and you as well), I would not have done so. The conversation on the E2E site is very helpful. Thanks, Jack
  2. Hi. A while back I had the need to send two bytes of data to a digital potentiometer without changing the state of chip select pin between the two bytes. I ended up modifying the SPI library and calling it altSPI. Essentially, the only change was to add two defined things called trans2ByteA and trans2ByteB. The first of these selects the chip and transmits the first Byte. The second transmits the second byte and then de-selects the chip. These are defined in altSPI.cpp as in the code below. The library can be found at https://github.com/SmokyMountainScientific/altSPI. If I were to do this again I would define a third function that transfers a byte without changing the CS state at all. uint8_t altSPIClass::trans2ByteA(uint8_t data) { return transfer(slaveSelect, data, SPI_CONTINUE); } uint8_t altSPIClass::trans2ByteB(uint8_t data) { return transfer(slaveSelect, data, SPI_LAST); }
  3. JStat60

    Noise in ADC

    Thanks for the suggestion @PTB but I dont think that is the problem. I am powering these through the USB port on my computer. I am also using the same micro USB cable and there is no change in the quality of data between trials. That is, a good board will always give good readings and a bad one will always give bad readings. Jack
  4. JStat60

    Noise in ADC

    Hi, I have a non-profit (Smoky Mountain Scientific, smokymtsci.com) that develops and sells low cost instruments for science education. One of our instruments incorporates a Tiva-C launchpad that outputs a pwm voltage and measures voltage and current passed in electrochemical reactions. I recently purchased a fairly large batch of Tiva launchpads from Mouser and I am having trouble with noise in the analog read channels for about 1/4th of the boards. We have been building and selling these instruments for a couple of years now and have never had this problem before. To test the boards, I send a pwm signal through a simple low pass filter (a resistor and a capacitor) then read the output on two channels (A11 and A8). The attached figures show examples of output from a good (file Board46) and a bad (file Board37) boards as displayed on our user interface. This seems to be a hardware problem and I dont know how to go about resolving it. Any recommendations? Thanks, Jack
  5. JStat60

    Tiva C UART

    Does this mean that the solution to this problem has been posted? If so, where? I am trying to link together four tiva launchpads (TM4C123...) and have them communicate using Serial2, Serial3 and Serial4. I want to use an array of serials to simplify the code but I cant get the modules selected. When I try serial[j].selectModule(module[j]); I get the error message "class HardwareSerial has no member named selectModule". Any ideas? Thanks, Jack
  6. Hi Folks, I recently designed a Booster Pack that I intended to use as a recording pH meter. The idea was that it would have a couple of British telecom analog (BTA) connectors that you could use to plug in a pH probe from Vernier instruments. The problem is that I assumed that the pH probe was comprised of a pair of passive electrodes, when in fact it has an amplifier built in and requires power and ground connections in addition to an output. This means that it cant be used as a pH meter (at least not with the Vernier probe), but you can use it for data logging. Of course there are limitations on the voltages you can measure (zero to vcc) and time scale resolution (limited to > 5 ms or so by serial communications over the USB), but I suspect there are applications where this would still be useful. The project is described on a couple of web pages and the source code has been posted to GitHub. This write-up describes what I have done and has links to the Eagle files, Energia code, and Processing code for the GUI. It also has a screenshot of the GUI so you can kind of see what is going on. The board design has been shared on the OSH Park web site, so you can just order a set of boards from them if you so desire. Jack
  7. We have been working to develop a low cost, three-electrode potentiostat for use in science education and environmental monitoring. This is a computer driven instrument that is appropriate for teaching at the university (undergraduate) or perhaps high school or home school level. It can be used to teach physical chemistry concepts and can be used to quantify things like metals in water. At this page, we describe using the instrument to measure lead in water at concentrations as low as 44 ppb. The instrument (called the WheeStat) is comprised of a Stellaris / Tiva LaunchPad, a booster pack, Energia software, a user interface (written in Processing), and a set of electrodes. All hardware and software is open source. Descriptions can be found as research notes at PublicLab.org. We are in the process of getting a kit put together that will have all the hardware and software needed (including the LaunchPad and a set of cheap electrodes) that will retail for $100. The kit is described here. Of course, you could build your own using our descriptions, but buying retail will allow us to continue developing other science ed hardware / software (see our web page). You should soon be able to purchase a kit from here. A user's manual is available here (the online users manual includes a couple of videos that demonstrate the user interface). The Energia and GUI software are available from here. A description of setting up the instrument is here. Let me know if you have any questions. Best regards, Jack
  8. JStat60

    Energia Tiva USB support

    Hi Folks, Hope you don't mind answering some possibly dumb questions from someone with very limited coding experience. I recently figured out that I could not communicate with my Stellaris / Tiva launchpads the "device" USB connection. It appears to me that this is the issue that you are working on. Is that correct? If you are able to accomplish what you are attempting, will it be possible to communicate with the launchpads without downloading and installing the ICDI drivers? I would like to use some launchpad based instruments to teach chemistry labs and I foresee installing the drivers on the student computers as a major obstacle. If this is not what you are working on and there is a simple answer to my problem, I would be grateful for that info. Thanks, Jack
  9. Hi, I appreciate the help. It has taken me a while to get back to this and I am still having issues. I have tried workaround #1 above and got the following error message: "SYSCTL_PERIPH_TIMER2 not declared in this scope". It will accept ROM_SysCtlPeripheralEnable(TIMER2) without generating the error, but that does not get the program working. I am trying to control a digital pot using SPI module0 and I am watching the SPI clock with an osciloscope. When I comment out the analogWrite(PB_0, 100); command I can see the SPI signals on my scope but the program hangs up when I try to run the analogWrite and gives no output on the clock. I dont believe that there is a hardware incompatibility issue since I have used this combination successfully before (in the previous Energia version). I am pretty new to digital electronics and I really wouldn't know where to start with workaround #2. Thanks again for the help. Jack
  10. @@energia, I have been using the Stellaris LauchPads (EK-LM4F120XL Rev and a PC running Windows 7. I do have some of the Tiva boards but I did not try this out with them. I have had this problem with multiple programs. In addition to the modified blink sketch reproduced in my 13 Feb post, I was unable to run a rather involved program that can be found at https://github.com/SmokyMountainScientific/WheeStat5_0/tree/master/WheeStat5_0. A third test program (presented below) Incorporates a pwm output into the setup of AnalogReadSerialOut. When the pwm output is on one of the "non-functioning" pins, no output is written to the serial port (when using the most recent Energia revision). The code compiles and loads without any error message coming up, but nothing comes up on the serial monitor. If the analogWrite command is executed on a "working" pin, like RED_LED, the LED lights up and the expected string of numbers comes spooling out of the monitor. I first saw this problem with a sketch written to run a pH meter (which I could post f someone wants to read, but seems like overkill). Please let me know if anyone else sees this kind of issue with the new Energia revision. Jack //////////// modified ARSO sketch ///////////////// void setup() { Serial.begin(9600); analogWrite(PB_0, 50); } void loop() { int sensorValue = analogRead(A3); Serial.println(sensorValue); delay(1); }
  11. Thanks for the replies. This appears to be a problem with the newest version of Energia (0101E0011). I recently loaded the newer version and had not gone through and tested it with older code that I knew worked with the previous version (0101E0010). Yesterday I tried loading a program using the new version and the program failed to run. After a prolonged bout of mild cursing, I discovered that the problem was with a PWMWrite command on pin PB_6. Thus, it appears that port B has problems with the new software that did not occur previously (ie, not a hardware issue). I re-installed 0101E0011 and again could not get PWM outputs on PB_0 or PB_6 (again, it did output to PB_5 and RED_LED). Re-loading Energia 0101E0010 fixed the problem. The old program works as it had before. Jack
  12. Thanks for the response. While the original code invoked serial communications, the modified blink program did not. I would consider the possibility that the history of the board could affect its response, except that I was unable to get an analog output from the brand new board. Still it is good to know that serial communications affect what you can and cannot do with various pins. This is still all pretty new to me and that is not something that I would have guessed. Thanks again, Jack
  13. Hi, I use Energia with a Stellaris LaunchPad and I can write pwm signals to some pins but not to others. I have no trouble writing to the red, green or blue leds, or to PB_5. I cannot seem to get a pwm signal out of PB_0 or PB_1. I thought that I might have damaged my LaunchPad so I tried with another board and got the same result. Guessing that I could have two damaged boards, I got a new one out of the box and it behaved in the same way. All the pins in question should be able to output pwm signals (according to the energia reference page). The code I am using to test the output is just a modified blink sketch (copied below). It is not a big problem to rewire my hardware, but there appears to be a problem somewhere. Am I missing something simple? Thanks, Jack ////// modified blink to test pwm output on refPin //////// int refPin = RED_LED; void setup() { pinMode(refPin, OUTPUT); } void loop() { analogWrite(refPin, 100); delay(1000); analogWrite(refPin, 0); delay(1000); }
  14. JStat60

    SPI with 16 bit data

    Problem solved. This was a hardware issue. I guess I cooked the digital pot while trying to solder it to the board. Replacing the pot resulted in behavior predicted for my test circuit. In case anyone is interested, I have pasted the energia code I tested the pot with below. The circuit is described as well. The sketch uses the trans2byte commands described above and the SPI library from Reaper7 and Rei Vilo. Sorry for the confusion. Jack /* Sketch for testing MCP 4231 digital potentiostat with volatile memory. modified from the Digital Pot Control example that comes with Energia Originally by Tom Igoe, Rick Kimball, Heather Dewey-Hagborg, 2005 to 12 Spi module 0 requires SPI library from Reaper7. The circuit: CS, SCK, and SDI attached to respective module zero pins (CS(0), SCK(0), MISO(0)} Pin P0A connected to VCC, Pins P0W, P0B, P1W and P1A all connected, Pin P1B connected to A11 with a 10 Kohm resister between A11 and GND. This gives: VCC-R1-(R2, analogRead)-R3 (10Kohm)-GND by cycling values to the two pots, values of R1 and R2 can be changed. Values of R1 and R2 can be determined from serial output of analog signal. * MOSI - to J1 pin 8 * CLK - to J2 pin 11 (SCK pin) P1.5 */ #include<Energia.h> // required to get spi to work. #include <SPI.h> // include the SPI library from Stellarisiti #include "wiring_analog.c" int gain0; int gain1; unsigned int address1 = 16; unsigned int address0 = 0; #define Iread_pin A11 //J1 pin 2, Analog read current, was A3 unsigned int iRead = 0; // hight pulse current read void setup() { SPI.setModule(0); SPI.begin(); SPI.setClockDivider(SPI_CLOCK_DIV64); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE0); pinMode (Iread_pin,INPUT); Serial.begin(9600); // begin serial comm. at 9600 baud ///////// header ////// Serial.print("gain 0"); Serial.print('\t'); Serial.print("gain 1"); Serial.print('\t'); Serial.println("Iread"); } void loop() { ///////// ramp up R0 holding R1 constant //////// for (int m=0; m<128; ++m) { gain1 = m; gain0=64; digitalPotWrite(16,gain1); //write to channel 1 digitalPotWrite(0,gain0); // write to channel 0 Serial.print(gain0); Serial.print('\t'); Serial.print(gain1); Serial.print('\t'); delay(20); readVolts(); } for (int n=0; n<128; ++n) { gain0 = n; gain1 = 64; digitalPotWrite(address1,gain1); //write to channel 1 digitalPotWrite(address0,gain0); // write to channel 0 Serial.print(gain0); Serial.print('\t'); Serial.print(gain1); Serial.print('\t'); readVolts(); } } int digitalPotWrite(int address, int value) { SPI.trans2ByteA(address); SPI.trans2ByteB(value); } void readVolts() { unsigned int iRead = 0; for (int i =0; i<=15; ++i){ iRead += analogRead(Iread_pin);} int mVi = (iRead)/16; mVi = mVi*3558/4098; // digital reading converted to mV Serial.println(mVi); }
×