Send collected data to windows computer through USB

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

Hi Guys

 

I have a project in mind but I am not sure what the easiest solution will be. I have googled but i cannot get the answers I am looking for.

 

So the idea is to have an embedded device that collects data from the environment. This data will be stored in the EEPROM of the microcontroller. I want to simply plug the embedded device into a windows desktop PC or laptop via a USB cable whereby the data in the EEPROM is transferred to the PC hardrive to analyse further. I want all of this to happen automatically and save the file on the desktop automatically in a .csv or .txt file. So as soon as the cable is plugged in, a light flashes red on the embedded device and green once its finished. I want this be extremely simple for the user. Plug and play if that makes sense

 

So some questions with regards to this:

 

1. Do i need to write a program on the PC in python (I can program some stuff in Python) or some other language to interface with the microcontroller once it gets plugged in or can i do without this? Just thinking about it I would write a small GUI python program that gets installed that acts as a interface for the user to download the information. For Example the user would double click the .exe on the computer, a small GUI pops up with a button that says download. You then plug in the device via usb and click download to save the .csv or .txt file to the desktop.

 

2. Can this program above act as a driver to interface with the embedded device or do i need a different driver? Do i even need a driver?

 

 

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

This sounds like a perfect project for an Arduino, start with an uno to get your code working then upload to a pro-mini or nano for your completed sensor.

I believe there is an example of a "datalogger" in the included examples in the IDE.

 

Jim

 

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

share.robinhood.com/jamesc3274

 

 

 

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

There are many different ways you can achieve this. The simplest IMO would be to use a UART-to-USB IC (such as an FT232) and simply transmit the data over UART. You can use the +5V of the USB to detect when the device has been connected to a PC to kick off transmitting your data.

You'd need someway of placing the received data into your .csv/ .txt file, this can anything from a simple program up to a custom written driver. Beware though that if you opt for a simple program you'd need to make sure it was running before connecting else when the device gets plugged in nothing will catch the data it sends. This is why a driver may be better...

 

Edit: Jim's suggestion of using an Arduino for hardware is probably even better since an Arduino typically features a UART-to-USB IC. But you'd still need some way of getting the data from the Arduino onto your PC as I mentioned

Last Edited: Wed. Aug 30, 2017 - 07:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys for the great advice. Mentioning the arduino made me think of doing the following:

 

Using the ATmega16u2 microcontroller as the brain for the embedded device. This will collect and store the data to EEPROM. This chip already has the capability of transferring serial data to the PC via a standard USB cable if i understand correctly? So this will essentially be killing two birds with one stone?

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

What is your experience building micro's from scratch?  Why not use readymade h/w (arduino) for your project and concentrate on the s/w development part?

USB projects are not for beginners!  Yes you could do as Howard suggests, but that is already done on the Arduino!  Just plug and play.

 

 

Jim

 

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

share.robinhood.com/jamesc3274

 

 

 

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

calvingloster wrote:
Using the ATmega16u2 microcontroller as the brain for the embedded device. This will collect and store the data to EEPROM. This chip already has the capability of transferring serial data to the PC via a standard USB cable if i understand correctly? So this will essentially be killing two birds with one stone?

 

The ATmega16U2 does indeed have built in USB, but programming it's USB peripheral is no simple feat, and many 'freaks here will strongly discourage you from taking on a native USB project unless you have a reasonable amount of experience and know what you're doing.

 

ki0bk wrote:
Yes you could do as Howard suggests
 

In truth I actually think your suggestion of simply using an Arduino is much better so I retract my suggestion ;)

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

I have quite a lot of experience "relatively speaking" with regards to stand alone avr 8 bit microcontrollers. I generally never use my arduino to do anything. I etch my own PCB's and normally write my own libraries in C# to drive different modules. I program all my projects using atmel studio via my ISP mk2 programmer. I personally don't like using arduino as it hides some of the detail.

 

I have an idea of what i need to do for this project i would just like to pick some brains on this forum as there are some extremely intelligent people on here that know a lot about embedded design. My idea is to have my embedded device be an etched PCB with USB connector soldered on it and all the other stuff i need. The arduino is too expensive and big. i want this to be a single function embedded device that has a single purpose. to connect to the PC and send its data.

 

So i guess i could use a ATmega U device as these have USB hardware build into them. I will do research on how this harware works and how i need to program the chip to interfece with usb. 

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

Howard_Smith wrote:
In truth I actually think your suggestion of simply using an Arduino is much better so I retract my suggestion ;)

 

I think your suggestion was great as it made me think to use the microcontroller the arduino uses for USB interface as the brain of my embedded device.

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

Here is a link to a similar project:  https://github.com/remuslazar/ar...

 

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

share.robinhood.com/jamesc3274

 

 

 

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

Howard_Smith wrote:
The ATmega16U2 does indeed have built in USB, but programming it's USB peripheral is no simple feat, and many 'freaks here will strongly discourage you from taking on a native USB project unless you have a reasonable amount of experience and know what you're doing.

 

I want to learn so i think i will take on this project challenge:)

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

calvingloster wrote:
I want to learn so i think i will take on this project challenge:)

 

Then check out V-USB as a starting point.

 

Jim

 

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

share.robinhood.com/jamesc3274

 

 

 

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

Thanks Jim i will check this out.

 

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

ki0bk wrote:
Then check out V-USB as a starting point.

Doesn't V-USB implement USB purely in software via bit banging? The device the OP is considering to use has built in USB, and perhaps Lufa would be better suited? (unless I'm missing something related to V-USB that makes it useful in this case?)

Last Edited: Wed. Aug 30, 2017 - 08:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Howard_Smith wrote:
you'd still need some way of getting the data from the Arduino onto your PC as I mentioned

The simplest way would be to just use a terminal program to capture the received text to file.

 

Job done.

 

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

awneil wrote:
The simplest way would be to just use a terminal program to capture the received text to file.

And the next simplest would be to have the USB device be a CDC and implement a virtual com port, and the write a trivial program on the PC side that opens the COM port, sends a "dump" command dto the AVR whereupon the avr dumps the data onto the virtual COM port and the PC program reads it from there and stores it on the PC. Almost all programming environments can handle COM ports with ease. (C. C++. Many scripting languages. Java/Groovy being a little harder to convince, but AFAIK it can be done.) If Python can do COM ports, then go with that. Otherwise perhapss C#/.NET (assuming we're talking Windows here).

 

Anothe possibility is to use a USB-enabled AVR and implement a mass storage device - i.e. something that behaves like a USB Memory Stick. Insert the device into the PC and just grab the file from the UDB device as you would do with any USB memory stick.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Howard_Smith wrote:

ki0bk wrote:
Then check out V-USB as a starting point.

Doesn't V-USB implement USB purely in software via bit banging? The device the OP is considering to use has built in USB, and perhaps Lufa would be better suited? (unless I'm missing something related to V-USB that makes it useful in this case?)

 

Yes your right, LUFA would be the way to go in that case!

 

Jim

 

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

share.robinhood.com/jamesc3274

 

 

 

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

JohanEkdahl wrote:
If Python can do COM ports

Yes, it can: http://pythonhosted.org/pyserial/

 

laugh

 

 

Another possibility is to use a USB-enabled AVR and implement a mass storage device

Or have the AVR record to an SD-Card, which can then be removed and popped into a PC for reading.

 

 

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: 1

Calvin,

       While I can appreciate your ability to make your own PC Boards, and your desire to use an AVR that has a USB peripheral in it, I would strongly suggest that you take the advice of the others and go the Arduino route for the 'get your feet wet' on this project.  You can get 5 Unos for under $30.00 here in the states on Ebay, and if you do not mind waiting a couple weeks, you get even better deals out of China directly.  The serial port is already there so all you need to do is download a simple sketch to confirm that the USB comms work and you at least have a known working platform to start with, rather than a homemade board that if something is wrong, it's anyone's guess what it could be.

 

Once you have your basic datalogger working, and transferringdata to your PC application THEN I would say look for a premade board with an AVR on it that has native USB in it.  Like this one:

 

https://www.adafruit.com/product...

 

Then you can start exploring LUFA, and possibly the Virtual Serial application.  I used Virtual Serial for an RFID reader project and it did what I needed, but the learning curve was really steep, and it took a lot of help from a few freaks here to get things working properly.  The AVR was teh 32u4 come to think of it...just like the one in the link I referred to.

 

Point is, it would benefit you to break your project up into phases and conquer/master each phase one by one, rather than jump right to the very end, and wind up with a project with no known solid starting point, and a very LONG thread that keeps going in circles leaving everyone with a bad taste in their mouths, and nothing accomplished.

 

Just my two pence, YOMD.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

I agree with Jim. Whilst it always good to have a challenge. Hand soldering a QFN part on a good pcb has a kartman rating of around 6/10. 10 is near impossible, 1 is piss easy. So 6 is 'challenging' - you'd better be prepared to fail and/or have a soldering iron with a fine point tip and lots of flux gell. A hot air tool comes in handy as well. Then factor in your own etched pcb that you need to get 0.05" pad spacing without shorts and no solder mask - just achieving that without specialised etching stuff is probably hovering around an 8 or more.

With this hi-tech stuff, it pays to choose your battles.