Pages: [1]   Go Down
Author Topic: [solved] debugging atmega328 w/ pl2303 (ebay usb $1.50 adapter)  (Read 811 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

morning all. apologies if this is in the wrong section, couldnt decide where to put it. this is not a 'how do i upload a sketch with this cheap adapter' question. i simply want to debug a breadboard atmega328p (3.3v 8Mhz). few months ago i was playing with an attiny85 and this adapter, and i got it talking fine, i cant get squat out with my current setup. any code (using examples) simple Serial.print("hello"); etc etc. im using the 3.3v output on the adapter, ground on the adapter, and rx line via 1k resistor to the tx line on the atmega. any advice appreciated. thank you.

http://www.ebay.com/itm/1pc-PL2303-USB-To-RS232-TTL-Converter-Adapter-Module-F-Arduino-CAR-Detection-GPS-/271234585265?pt=LH_DefaultDomain_0&hash=item3f26d752b1
« Last Edit: July 23, 2013, 01:06:48 pm by grendle » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It appears to have RX and TX lights ("Two data transmission indicator can monitor data transfer status in real time").  Do they blink in the expected patterns?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

no, ive used 2 different atmegas to make sure one wasnt damaged. the power light is on - on the adapter. also, i have 2 of these adapters im trying, just in case one is damaged. i usually order stuff in twos. to me this should be a simple thing lol, very confused. the breadboard setup is minimal, atmega, xtal, xtal caps, thats it. (the entire circuit is a receiver for weatherstation. but since it didnt work from get go, im working with stripped breadboard. also, on an uno without sdcard this works fine. im building it on a breadboard to stay with the 3.3v because i want to add the sdcard, but i cant even get it to spit out "hello world" to the pc lol.
Code:
// receive w/ sd card support. add clock?

#include <SD.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

const int chipSelect = 8; //sd card
const uint64_t pipe = 0xE8E8F0F0E1LL; //pipe

typedef struct{
  float T; //temperature
  float RH;
  float HI;
  float DP;
  float pressure;
}
payload;
payload ard1;
RF24 radio(9,10);



void setup()
{

  ADCSRA &= ~(1<<ADEN); //Disable ADC
  ACSR = (1<<ACD); //Disable the analog comparator
  DIDR0 = 0x3F; //Disable digital input buffers on all ADC0-ADC5 pins
  DIDR1 = (1<<AIN1D)|(1<<AIN0D); //Disable digital input buffer on AIN1/0

  //  power_adc_disable();

  Serial.begin(57600);

  pinMode(7, OUTPUT); //write error
  pinMode(8, OUTPUT); //cs sd card

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    digitalWrite(7,HIGH); //error
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
  File dataFile = SD.open("datalog.csv", FILE_WRITE);

  if (dataFile) { //file header

    dataFile.println("Decimal Minutes (GPS): N32 31.581409999999998 W86 23.3472 Date: ");
    dataFile.print("Temperature");
    dataFile.print(",");
    dataFile.print("Pressure");
    dataFile.print(",");
    dataFile.print("Humidity");
    dataFile.print(",");
    dataFile.print("Dew Point");
    dataFile.print(",");
    dataFile.println("Heat Index");
    dataFile.close();
  }
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}

void loop()
{

  if ( radio.available() )
  {
    // Dump the payloads until we've gotten everything
    boolean done = false;
    while (!done)
    {
      // Fetch the payload, and see if this was the last one.
      done = radio.read( &ard1, sizeof(ard1) );
      Serial.print(ard1.T);
      Serial.println(" oF");
      Serial.print(ard1.pressure);
      Serial.println(" in/Hg");
      Serial.print(ard1.RH);
      Serial.println(" % Hum");
      Serial.print(ard1.DP);
      Serial.println(" Dew Point");
      Serial.print(ard1.HI);
      Serial.println(" Feels like");
    }
  }

  File dataFile = SD.open("datalog.csv", FILE_WRITE);


  if (dataFile) {
    dataFile.print(ard1.T);
    dataFile.print(",");
    dataFile.print(ard1.pressure);
    dataFile.print(",");
    dataFile.print(ard1.RH);
    dataFile.print(",");
    dataFile.print(ard1.DP);
    dataFile.print(",");
    dataFile.println(ard1.HI);



    dataFile.close();
  }
}


Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i found this from crossroads
quote:
So which is it? USB to TTL (0 to 5V signals), or USB to RS232 (+/- 10V signals)?
Sounds like it has a 3.3V output as well.
http://prolificusa.com/files/ds_pl2303HXD_v1.4.3.pdf
See page 18 for a typical usage of the chip with a RS232 transceiver chip.

If TTL, you can connect the Rx & Tx to the appropriate pins on your Arduino; Tx and Rx.

If its RS232, then you need an RS232 adapter to bring the levels from +/-10V down to 0-5V levels.

Does your PC have PL2303 USB drivers installed?
end quote:

this may be my problem hmm? im using 3.3v, let me set it up at 5 v and see what happens.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yup that was it, works fine with 5volts. ok so this means the sd card moves to the actual weatherstation unit, and not the receiver. oh well, live and learn. thank you John! (and crossroads lol.)
Logged

Pages: [1]   Go Up
Jump to: