Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Laptop<->USB<->μcontroller : ways

0.00/5 (No votes)
19 Apr 2015 1  
Some ways in which laptops and microcontrollers communicate

Introduction

AsSC7 uses overlapped I/O with Arduino: Tx can be pushed while receiving and it seems full-duplex. AsProC9 uses overlapped I/O with asynchronous procedure calls with Arduino: an APC timer polls for Rx, but it is strictly half-duplex.

Using the Code

AsSC7

  • Connect Arduino to laptop via USB and check which COM port it is.
  • Load in Arduino WriteAndRead.
  • Launch AsSC7, choose the same COM port in combobox, push Start, then push Tx when enabled: messages will appear in editbox.
  • Push Pause to stop receiving from Arduino without closing serial port: 00000... will pop up.
  • Push Tx when enabled... Again and again Pause and Tx.
  • To close serial port, push Stop.
  • Push x system command to close app.
  • EXE app has almost no error checking and messages. It presumes all devices work correctly.

AsProC9

  • Connect Arduino to laptop via USB and check which COM port it is.
  • Load in Arduino WriteAndRead. Launch AsProC9, choose the same COM port in combobox: CRichEdit2 is white.
  • Push Communicate, CRichEdit2 is Azure and wait for response: white CRichEdit2. TimerAPC polls for Rx.
  • Timer has a weak algorithm to vary its period depending on frequency of received strings: check or uncheck checkbox and see StringLength, NumRead and ZeroLen in the CRichEdit2.
  • While communicating, wait for an arbitrary moment and push Stop: CRichEdit2 gets pink and some strings received from Arduino or locally written, will be shown.
  • Stop button uses an estimated interval not to stop before transmission from microcontroller is finished: if not, Rx buffer would get dirty.
  • Each app has its own WriteAndRead.

SyScUc8

While the previous two are asynchronous, this one is synchronous. Connect Arduino to laptop via USB and check which COM port it is. Load in Arduino WriteAndRead. Launch SyScUc8, choose the same COM port in combobox. Push Communicate: russian is displayed in Rx. Push again Communicate, till it lasts (5 sec). Then push Stop: with x syscommand can close app. Arduino will flash led 13 to signal it. If last row in WriteAndRead Serial.end(); is inserted, after pushing Stop, Arduino must be reset to redo communication.

Points of Interest

In WriteAndRead.ino, I used crt functions. They seem to work fine.

References

  • MSDN
  • Internet samples
  • Jeffrey Richter, Stanley B. Lippman & Josee Lajoie

History

  • 18th April, 2015: Initial version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here