How to make a PC program to send information to atmega328p

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

Hi everyone, I have a program running on an atmega328p (it's an arduino UNO but I program it in C using atmel studio 7) wich has 3 variables and I want to make a program to run on a PC for the user to set the values of those variables. Is there any tutorial on how to do something like this? Or programs to do this easily?

 

I've seen some videos about serial communication using visual studio but they are all very vague.

Last Edited: Sun. Apr 9, 2017 - 10:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Wrong forum, I will move this to General Programming.

 

Just use a terminal program and a serial interface and you are all done.  YOu will need to write a function in your app code to support this.  Very simple to do.

 

Do these variables need to be restored on power reset?

 

JIm

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

Please Read: Code-of-Conduct

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

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

Are you using the data from the Arduino to control a program or process on the PC?  Is this a commercial or home-brew program on the PC?

 

Or - are you sending data from the PC that the user is entering/typing while the programs (on both the PC and the AVR) are running?

 

Generally to write a program on the PC that interacts with data received from an external AVR requires a programming language tool on the PC.   Often this is Visual BASIC or Visual C.  Use these programs to determine the number of USB COM ports that the PC can detect and what their ID numbers are.  Assign your VB or VC application to process data received from the user-selected COM port.   Then use a USB-serial interface to physically make the COM connection between the PC and Arduino.   In the .ino file used by the Arduino program/sketch, use Serial.read() and Serial.write() to exchange data with the PC.

 

If the user is typing data from the PC to the Arduino, just use a terminal program on the PC side, or the Arduino Serial Monitor.
 

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

M_Luis wrote:
Is there any tutorial on how to do something like this?
Somewhat; the following is for Arduino and Universal Windows Platform (UWP, Windows 10 PC and phone, Windows Server 2016) (Arduino IDE, Visual Studio 2015) :

https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/SerialArduino

Shows how to use the Windows.Devices.SerialCommunication APIs to communicate with an Arduino device.

...

This sample allows the user to configure and communicate with an Arduino board that has simple wired circuitry consisting of 4 LEDs and a temperature sensor.

...

via

Microsoft

Microsoft Windows USB Core Team Blog

What is new with Serial in Windows 10

by George Roussos (Microsoft)

July 29, 2015

https://blogs.msdn.microsoft.com/usbcoreblog/2015/07/29/what-is-new-with-serial-in-windows-10/

...

 

2.   A Windows Runtime API for communication with Serial devices

...

Windows 10 SDK includes two Universal SDK samples illustrating this API:

  1. CustomSerialDeviceAccess SDK Sample
  2. New SerialArduino SDK Sample from above //build talk is now available including C# and Arduino sketch source code.

...

 


Microsoft

Microsoft

Windows

Intro to the Universal Windows Platform

https://docs.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide 

 

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

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

The user just types on the PC data that needs to be sent to the microcontroller.

 

I know that I can use a terminal program, but I want to create something more user friendly, to be easily used by someone that doesn't know how to work with a microcontroller.

 

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

but I want to create something more user friendly,

Then build some nice, user friendly MENU inside the micro and use the terminal program.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
Then build some nice, user friendly MENU inside the micro and use the terminal program.
yes+1

 

Or, if you "must" have a custom interface, build a custom front end over an existing terminal program.

Many are Open Source (e.g. TeraTerm, PuTTY, MinTTY, etc.).

David (aka frog_jr)

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

We're so spoiled for choice these days. 'Firmata' seems to be popular although I've not used it. For most of my industrial instrumentation designs, I used Modbus. Having 'rolled my own' stuff for many years, it does make sense to use a protocol that is known a documented - this usually means there are existing tools to test with.

One protocol I used for my garage lighting control was 'OSC' - open sound system control. There was a free app on the iPhone that was customisable so i could have buttons and sliders. This worked well. It works over UDP, so I used a enc28j60 ethernet interface and hacked the tuxgraphics ethernet stack to do UDP. This was done an a mega162 at 8MHz. I used ethernet as the light dimming code took most of the cpu time, so serial comms at any reasonable speed was a problem - the enc28 chip has 8k of buffer, so that solved the problem.

 

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

M_Luis wrote:

The user just types on the PC data that needs to be sent to the microcontroller.

 

I know that I can use a terminal program, but I want to create something more user friendly, to be easily used by someone that doesn't know how to work with a microcontroller.

 

You can use PureBasic to easily create PC programs with a GUI interface - See this post and this one.

 

 

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

see if this series gives you more information on how to go about it:

https://www.youtube.com/watch?v=krN6pWm6s6o

 

you can also use things like Excel & its built-in vba to do so:

http://webcache.googleusercontent.com/search?q=cache:oldwJx3v3tAJ:dev.emcelettronica.com/serial-port-communication-in-excel-vba+&cd=1&hl=en&ct=clnk&gl=us

 

an older post from way back in the day (using .ocx)

http://www.pencomdesign.com/support/relay_software/vba_software_example.htm

 

 

When in the dark remember-the future looks brighter than ever.

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

If you know C++, I also recommend Qt. There is a fully featured free community edition available, but this requires you to comply to LGPL v3 when distributing the software.

 

Qt is really easy to use once you understood how the creators think. You can easily click together a GUI and then program it to do stuff.

The main advantage here is that it features an abstraction layer for the serial port, this even makes it multi platform! The only problem is that the examples for the serial port provided by Qt themselves are really overkill and hard to understand.

If you need a simpler example, PM me and I'll give you my latest project involving Qt's serial port HAL.

 

-Patrick

"Some people die at 25 and aren't buried until 75." -Benjamin Franklin

 

What is life's greatest illusion?"  "Innocence, my brother." -Skyrim

 

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

My inclination is to put as much of the smarts on the PC side as practical.

I've generally used Python's serial module to interface with an AVR.

The pySerial module is "sold separately", but not hard to find: https://pypi.python.org/pypi/pys...

On windows machines, so is curses: https://pypi.python.org/pypi/cur...

 

Disclaimer: I've never used curses.  I've always wanted something either more or less complicated.

International Theophysical Year seems to have been forgotten..
Anyone remember the song Jukebox Band?

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

js wrote:
build some nice (sic), user friendly (sic) MENU inside the micro and use the terminal program.

-1

 

skeeve wrote:
My inclination is to put as much of the smarts on the PC side as practical.

+1

 

Also the PC is far better equipped for graphics,  prettiness, & general "niceness" of UI

 

Last Edited: Tue. Apr 11, 2017 - 06:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've never used curses.

Maybe 1 or 2 at times.....

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

You must be a Saint, John.

Ross McKenzie ValuSoft Melbourne Australia

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

On top of being royal you mean?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

You have a higher calling...

 

Ross McKenzie ValuSoft Melbourne Australia

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

All right already.

What are you guys hinting about curses?

International Theophysical Year seems to have been forgotten..
Anyone remember the song Jukebox Band?

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

skeeve wrote:

All right already.

What are you guys hinting about curses?

 

Here's a hint (Link).

 

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

Still unclear.

Are you hint

Chuck99 wrote:

skeeve wrote:

All right already.

What are you guys hinting about curses?

 

Here's a hint (Link).

 

Still not clear.

Are you hinting that there are lots of curseses?

International Theophysical Year seems to have been forgotten..
Anyone remember the song Jukebox Band?

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

avrcandies wrote:

see if this series gives you more information on how to go about it:

https://www.youtube.com/watch?v=krN6pWm6s6o

 

 

That's exactly what I was looking for.

Thanks. 

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

Good that they clarified it's a Serial COM port ...

 

cheeky