Microcontroller and Linux PC

For the first time I've been playing with Ubuntu past few days and love it.

I also dabble in PIC micros and was wondering after having seen how much you can do from simple commands in the Ubuntu terminal program, wouldn't it be possible to actually control a Linux PC somehow with a microcontroller -- by somehow interfacing the PIC to Ubuntu's terminal program (rs232?)?

The commands are simple ascii and they don't just run prgrams but control processes also.

??

Reply to
mkr5000
Loading thread data ...

On a sunny day (Mon, 27 Jul 2009 11:14:25 -0700 (PDT)) it happened mkr5000 wrote in :

You can control any Linux PC from a RS232 terminal. I still have an old RS232 terminal with CRT somewhere in the attic. If you were to program that PIC to wait for the prompt and then send one command at the time you can have the PC do anything. You may need to send a login and password too: Google 'linux RS232 terminal', you will find things like this:

formatting link

I dunno about bubuntoo, but the instructions are generic.

Reply to
Jan Panteltje

Quite easy to do (modulo the need to parse the responses, of course). Do some reading on /etc/inittab and getty (probably implemented as agetty nowadays). May be as simple, on the PC side, as deleting one character in inittab.

WARNING - don't get too creative when working inside inittab. Bad Things can happen. Be sure that you have a Linux boot CD, your native flavor or Knoppix or something, if you've not fiddled with this before so that you can recover the original inittab (make a backup, of course).

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

If you look in /etc/inittab, there are usually commented-out entries for the serial ports, e.g.:

# SERIAL CONSOLES #s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100 #s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100

If you uncomment those entries, then run "telinit q" to tell init to re-read the inittab file, you can log in via the serial port. To test it, you need another serial port (either on the same PC or a different PC, or a USB/serial converter) and a null-modem (crossover) cable (a modem cable won't work).

To connect a PIC to it, a PIC with a hardware UART is preferable, although you can bit-bang if you have to. You also need e.g. a MAX232 to convert between TTL and RS232 line levels.

You might want to run agetty with something like "-n -l /bin/bash" to skip the login, although that will give you a root shell. A custom script which does e.g. "exec su - guest" would be better.

Reply to
Nobody

Wow -- this is exciting.

I I've never even had a Linux op system on my PC till I put on Ubuntu the other day and the minute I saw what that terminal program could do, my little light bulb kept flashing this morning.

With windows you really don't have anything like that -- dos to some extent I guess.

I really want to just do an audio player for now and I bet I could do all the control functions and maybe even get data for an LCD readout somehow ?

The audio player in Ubuntu is way better than anything I've used -- and I can't get Ubuntu to crash -- I'VE TRIED.

Reply to
mkr5000

On a sunny day (Mon, 27 Jul 2009 12:55:35 -0700 (PDT)) it happened mkr5000 wrote in :

Oh, no problem: As root do: cd / rm * -rf

Do not blame me, if YOU typed it.

Reply to
Jan Panteltje

While I think Linux is great, I do have to defend Windows here: Not only does it have the old "command prompt" (cmd.exe), but pretty much every *NIX shell has been ported to Windows if you'd like to use it, and there's 4NT/Take Command from JPSoft if you really want a fancy (but Windows-only) shell. Additionally, there's Microsoft's PowerShell, which is almost closer to something like a Perl or Python shell than a traditional command prompt.

Have you tried WinAmp?

If you find the equivalent of Street Atlas USA or Streets & Trips for Linux, let me know -- other than specific engineering programs, those are one major type of software that doesn't exist. (There are plenty of programs that provide routing and use Internet maps, but none where you can get accurate, up-to-date maps for the entire country, including routing information.)

---Joel

Reply to
Joel Koltner

ux,

jor

t

e,

Tomtom GPS units run on [embedded] Linux.You can buy recent maps on theri site, so the maps exist. You will have to reverse-engineer one for the soft that uses the maps (grab the flash perhaps), then there is the display issue. I seem to remember that there _are_ Linux programs that use standard maps you can buy. Been a while since I looked into that. There is always google maps and google earth. if you have a net connection. Else a compass:-) hehe

Reply to
Jan Panteltje

Sure - just configure your serial port as a virtual console.

Mind if I ask why?

Cheers! Rich

Reply to
Rich Grise

HI Jan,

Perfectly good approach, but I'm not really all that interested in doing that myself -- I'd much rather pay someone, e.g., $50 to have already done so and then packaged it up nicely, like Delorme and Microsoft do.

"I seem to remember that there _are_ Linux programs that use standard maps you can buy."

I've never found any that run on general-purpose PCs/Linux distros, and I have looked a couple of times.

"There is always google maps and google earth. if you have a net connection."

If I were close enough to civilization to need a net connection, I probably wouldn't need a map.

:-)

I did miss a plane once after getting lost in Chicago some years ago, so Google maps definitely would have helped there. I've never gotten lost out in the woods to date, but that's what I worry about more. I was once out, by myself, for a day hike but miscalculated how long the return trip down the mountain would take and it ended up getting quite dark before I finished: Despite being at least a little bit prepared (I had a GPS receiver, lightweight jacket, matches, a small knife, etc., and a "AA"-powered LED flashlight -- which is what let me see enough of the trail to keep going --), I was getting pretty freaked out. Once I made it back to the car, I got some food at a local drive-through, returned to the motel, locked the door, ate dinner, and pretty quickly went to bed, feeling far less "adventurous" than when the day had started. :-)

---Joel

Reply to
Joel Koltner

Let's take the example of a simple music player to start.

I wasn't really aware that beyond the GUI you had access to other "functions" in the way that a program operates and this is what I noticed in Linux. (or was I seeing things?)

I mean there are some occasions where, unlike Windows, to get something done you go to the Linux terminal and type in commands -- for an assortment of reasons.

I'm sort of lost regarding software when it comes to what lies between the end product (the GUI) and actual programming. I mean, I can write a good amount of VBNET and I can certainly click a mouse in a GUI but "shells" and commands are an area that I have never entered. (except dos, I suppose).

Going back to my audio player example -- I know that it would be easy enough in any op system to start and stop the "program" with commands -- but do (you think) I also have commands available to control volume, stop, play etc?

And ultimately have a PIC do it?

Reply to
mkr5000

Come to think of it -- I guess it really depends on "what" commands the application makes available to the user?

I may be sounding like a dunce but just trying to figure this out.

Reply to
mkr5000

With root privilege, crashing the system is fairly easy (it used to be as simple as "cat /dev/zero > /dev/kmem" - overwrite kernel memory with zeros, but that feature tends to be disabled in modern kernels).

Without root privilege, the easiest way to crash the system is with 3D games. The drivers for the 3D part of the video hardware tend to be permanently alpha-quality, as the hardware tends to become obsolete long before most of the bugs get fixed.

Reply to
Nobody

On a sunny day (Tue, 28 Jul 2009 06:20:13 -0700 (PDT)) it happened mkr5000 wrote in :

It all depends on the application. For a music player, to control volume, you can use a mixer, an other application... Can be as simple as using the amix program, use amixer -c 0 scontrols to get the simple controls.

Then you can for example do:

Set volume to 100%: amixer -c 0 sset 'Master',0 100

Set volume to 10%: amixer -c 0 sset 'Master',0 10

In my view, controlling a PC from a PIC makes little sense, as you can automate anything and everything on the PC itself (and have a real time clock at your disposal too) with scripts for example.

Consider creating this text, with an [any] editor:

while [ 1 ] do amixer -c 0 sset 'Master',0 100 sleep 1 amixer -c 0 sset 'Master',0 10 sleep 1 done

Save as file 'my_test' (without the quotes).

Now make it executable (any filename can be made executable in Linux). chmod +x my_test.

Start your music player. Now type, in some terminal: my_test. Enjoy.

Suggestion to read; man amixer man chmod man bash man ...anything...

An other useful command, if you have no clue, is the 'apropos' command to find references to what you want to know: apropos clue

I dunno if you can write in C, if you do I can recommend the very simple but also very powerful xforms library, it has the program 'fdesign' that will create C code for the GUI and all you then have to do is write the functions you want and fill in the callbacks.

formatting link
Takes 10 minutes or less to set up a simple GUI program with that. The GUI program can then call other programs, for example mpg123 (mp3 player) can be called from that GUI if it is supposed to be a music player, etc..

The other thing you need to know about is pipes in Unix, as it allows you to send the output of one program to the input of an other one, allowing you to chain programs together to do operations on data. cat *.txt | grep hello

The '|' symbol is a pipe. man cat man grep

Maybe, if all fails, look for a good online book about Unix / Linux, look at the source code of

programs for how people do it, that is another advantage of open source. Give it a few years :-)

Reply to
Jan Panteltje

Thanks Jan -- great info. I printed it out to study.

Reason I want a pic is that I want to get rid of the PC completely.

Do my own player with it's own chassis, lcd readout, and have the pic control all the functions -- therefore I can use front panel switches etc.

Have the pic control a small mini itx motherboard with ubuntu (or?) loaded.

I want it very "un-pc" looking.

I figure if the music player is a good learning experience there may be other projects to pursue -- with the "un-pc" thing in mind.

I think also I need to look into the world of small embedded op systems and hardware as well.

I'm completely uneducated in this area.

Just know my PC's -- pic programming -- enough vbnet to get by and how to use a breadboard and soldering iron.

Reply to
mkr5000

Building one's own MP3 player is a pretty popular project... you might want to take a look at what others have done too. E.g.,:

formatting link
formatting link

...Google can find many others.

Note that a regular old PIC doesn't have the power to decode an MP3 bitstream -- the various PIC/AVR controlled MP3 players you see out there tend to use a dedicated IC to perform the (computationally intensive) decode.

---Joel

Reply to
Joel Koltner

Do they have gas stations in your country? ;-) ;-) ;-)

Cheers! Rich

Reply to
Rich Grise

Not to worry - we were all newbies once. :-)

Has anyone told you about man pages yet? Or the HOWTOs?

Albeit, I admit I found that somewhat daunting - like, "Where is the list of what commands are available?" So I bought a copy of "UNIX for Dummies" for a few dollars and it helped me get started.

Have Fun! Rich

Reply to
Rich Grise

You might want to check these out:

formatting link

That's just one hit when I googled "linux SBC" without the quotes.

Have Fun! Rich

Reply to
Rich Grise

"The middle of nowhere" is *well* within the ~300 mile range of a car. :-)

At least in most parts of the country.

Most people who get lost in the woods (granted, on foot) are no more than 5 miles from a major road. (Although just finding "a road" isn't always a lot of help if you can't discern a road leading back to civilization from some old logging road that is seldom used...... this was the mistake James Kim made, turning from a lesser-used [but at least paved, named and reasonably well-known] road onto a logging road...).

---Joel

Reply to
Joel Koltner

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.