spo2 Pulse Oximeter (Mega48) Serial to PC connection

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am slowly getting back to AVR's and my SPO2 Oximeter is well on its way.

I am reading the values using ADC0 and the internal voltage ref using the Debug

in Atmel Studio and DebugWire Breakpoints with Actions (very slow)

 

So I am attempting to relearn serial communications

I bought the PL2303tausb that has 4 wires

Using putty (I could not get putty to work for some reason) so I used MicroRidge ComTestSerial

and connected an LED on the RXD line and when I send a character it blinks

When I ground the TXD it receives garbage as expected all is well.

 

Connecting to AVR is my question:

 

I assume I tie the ground wire to the AVR board, I am using 5VDC for the breadboard.

 

Just wondering about the USB Positive wire, just leave it disconnected?

Also the connections to the transmit and receive, Direct connect or use resistors?

 

 

I have not yet connected up my 14.7xx crystal or programmed the USART (although I did buy CodeVisionAVR full version so I will be getting to 

TFT/OLED stuff later.

I am ordering a new Hantek DSO5202P 200MHz so I can understand the signals I'm working with.

I will be using C# to program the software that displays the collected data.

 

 

 

 

 

 

 

 

This topic has a solution.
Last Edited: Wed. Oct 2, 2019 - 03:03 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

metron9 wrote:
I assume I tie the ground wire to the AVR board

Yes - you always need a common ground reference for these things!

 

metron9 wrote:
USB Positive wire, just leave it disconnected?

Some of these cables let you draw power from it (RTFM for specific details) - if you're not using that then, yes - leave it disconnected.

 

metron9 wrote:
connections to the transmit and receive, Direct connect or use resistors?

Assuming the cable is the correct voltage spec, direct should be fine.

Resistors wouldn't hurt.

 

None of this is specific to AVR.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just as a reminder:

AVR TXD -> RXD usbSerial

AVR RXD <- TXD usbSerial

AVR GND -- GND usbSerial

 

signals are crossed for serial comms.

Good hunting!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got it, Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See Tip #5, then!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Resistors are good, when the tx & rx get mixed up, the chance of roasting everything is reduced...Many of thee adapters come with no or wrong documentation.

 

When I ground the TXD it receives garbage as expected all is well.

That makes no sense. but making no sense often makes a lot of sense. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Oct 1, 2019 - 10:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Usually the only way that I can tell the RX from the TX is to actually look at the wires with an oscilloscope.  The TX from the PC will show serial pulses (default normal idle state is HIGH +5V)  when a serial terminal program is run [ComTestSerial] and keys are pressed.  This is the line that goes into the RX on the AVR.  This line will flicker an LED off with a slow baud rate, but at 115K baud or higher, the pulses may be too short to see any activity on the LED.  Touching the RX {into the PC} line to Ground will cause "switch bouncing" that will mimic a serial input signal.  This gives the random "garbage" characters on the PC terminal program's display screen.

 

I believe that you are right in leaving the V+ pin from the USB disconnected to the Vcc of your AVR target system if the AVR has its own power source.  Or you could use a Schottky diode [the ones with a 0.3V voltage drop when powered, vs the normal 1n914 silicon signal diode's 0.7V drop] with the anode on USB V+ and the cathode on the target's Vcc.  This will work as long as the AVR is running at +5V Vcc.  If the AVR is running at +3.3V, then it may not work to leave USB V+ disconnected {I haven't tried it}.  If your AVR system is 3.3v, then having the Schottky diode will keep the ~4.3V from the USB from overpowering the 3.3V.

 

Most people use USB-Serial adapters with the CH340G IC instead of the PL2303.  It can be hard to get a PC driver to work with the PL2303, and the CH340G is much cheaper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most people use USB-Serial adapters with the CH340G IC instead of the PL2303.  It can be hard to get a PC driver to work with the PL2303, and the CH340G is much cheaper.

Good to know I may need that.

 

I will mark post read. Thank's everybody for your kind responses.

 

I was able to make a rudimentary pulse output using the Break Point Action using this code.

Getting my serial input to a c# program where I can store the data is next.

I did order a  Hantek MSO5202D 200MHz, 2/16 Channel Mixed Signal Oscilloscope

A bit more than I need obviously since i am just playing with how stuff works but It's going to be a long winter by the looks of it.

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

metron9 wrote:
I am reading the values using ADC0 and the internal voltage ref using the Debug

in Atmel Studio and DebugWire Breakpoints with Actions (very slow)

...

I bought the PL2303tausb that has 4 wires

You nearly have the parts for a debugWIRE alternative if the PL2303 isn't a clone.

debugWIRE via USB UART | AVR Freaks

Microchip AVR GCC has an AVR GDB client, dwire-debug has an AVR GDB server, if a standard I/O operator interface to the debugger is acceptable.

Other IDE besides Microsoft Visual Studio (extensions) and Atmel Studio have GDB interfaces.

By CodeVisionAVR, dwire-debug would have a monitor-like interface (peek and poke of registers and RAM with breakpoints at CPU level)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need to interface with my c# program anyway and I am going to change to full JTAG programming with the chips that support JTAG

 

Pretty cool project though, I noticed one post said there was a break in the execution where there was no break point set.

From my other post on troubles with debugging switching to disassembly and not finding the C code, That program had some

out of place breaks as well, I copied the text of the program created a new project and pasted it in and everything works again.

Modifying code while break points are selected is the possible problem I was told so perhaps that is happening to their break point without a break point set. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An advantage of AVR JTAG OCD is program memory breakpoints have a maximum count of two to four; after those are set, AVR BREAK instructions are placed into program memory.

AVR debugWIRE OCD has program memory breakpoints only by BREAK.

 

There's also a breakpoint anomaly in Microsoft Visual Studio that is, IIRC, linked to a solution; Atmel Studio shares that anomaly.

 

"Dare to be naïve." - Buckminster Fuller