Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Can a Basic Stamp support 2 serial ports?

Status
Not open for further replies.

Scruit

New Member
I want to make a GPS car locator using a GPS and a cellphone with inbuilt modem. I would make a data call to the cellphone and it would relay the GPS data to me.

The GPS sends data via serial, and the phone accepts data via serial. I cannot connect the two directly together for two reasons;

- the deluge of GPS data confuses the modem when it is not in a connected state
- If there is no GPS signal at the time I call, I'm out of luck.


I want to make a logic device with two serial ports (one for GPS, one for phone) and a data buffer. It would listen in on the GPS port and parse out the co-ordinates from the data. If the co-ordinates are present (has GPS signal) then it would store those co-orindates in the data buffer. If the co-oridnates are not present (No GPS signal) then it woudl ignore the data (and the data buffer still contains the last good co-ordinates).

It would also listen to the cellmodem port. If it sees the word "CONNECTED" come across the line then it would start relaying the data from the data buffer. If it sees the word; "NO CARRIER" it would stop relaying.


All the basic stamps I have seen so far only have one serial port.

- Is this a reasonable project to attempt with a basic stamp?
- How do I get two serial ports with a single basic stamp?
- Can I hook up an RS232 chip to some of the data lines on the stamp and use that as my second serial port?

- Is there an alternative to using a basic stamp? It would be mounted in a car and run 24x7, so a computer is not an option.

Thanks!
 

Noggin

Member
I'm doing this exact thing. Had a car stolen back in September of '02 and now its become a senior design project. Found this site about a week ago when looking up options for building a 5 to 6 amp 5v power supply.

I'm using an Atmel ATmega128 microcontroller since it has two serial ports. The chip can be bought in bulk for $4 or so and then you can find plans to build a dev board, or you can spend about $200 and buy a dev kit which will come with a chip. It can also be programmed in C or assembly. If you want the dev kit you need an STK500 AND an STK501 (which is an add on for the 500 which gives the ATmega128 support).

My modem is a MultiTek GSM 1900 modem. It cost $250 for the dev kit, which really isn't that necessary. Its a standard serial interface, just gotta get 5v to it and some kind of adapter to get the data to it. Its also quite small, much smaller than a deck of cards. Operates on 5v with a peak current demand of 1.7 amps. The modem alone can be bought for $150.

The GPS unit is a Garmin, but I've forgotten most of the specs on it.

This thing is SOOOO close to being done its not funny. The only thing left to do is actually assemble the power supply and add a few lines of C code to allow the use of a security code and also to specify what number to call.

In addition to being able to send the location, it also has the ability to turn off my (the) car and also moniters the car alarm, so that if the alarm sounds and it begins moving (it also can calculate the distance from where it was when the alarm first sounded) it'll initiate the connection to the PC. The PC accepts the data (and can also send control commands to it) and then hangs up. After a few minutes, the cellular modem will call again to report its new position.

https://www.ece.msstate.edu/classes/design/ece4532/2003_spring/car_alarm/

Click on deliverables, then for April 29 get the final design document. Almost everything we've done is in there, and if you dig around enough you can find some of the old Atmel source code before we had modem support. Don't laugh at the source code though, that was my first attempt at programming it and its quite crude in many places ;).

I'm very interested in what you can say about your project :)

Oh yeah, the modem in our design document is NOT what we are using now. The old was is FRIED, and was WWWAAAAAYYYYY more complex than this one.
 

Noggin

Member
Oh, just wanted to point out that if you want to call your cellular modem from your computer's modem you want to have a VOICE connection, not data. The two modems will automatically negotiate the connection and its as simple as using hyperterminal and typing letters to send and receive.

I THINK with a data connection you are forced to go over TCP/IP and it'll get much more complex than just sending and receiveing ASCII data. I could be wrong however....
 

Scruit

New Member
With the modem... The phone is a Kyocera 2035 that has a DataOnly option. When the serial cable arrives I'll experiment with it. It's only a 14.4 connection but that's fast enough for NMEA GPS data.

I'll do some research on the modem you suggested, just in case the kyocera doesn't work out.

I found a similar microprocessor to your, the Rabbit 2000. It has 4 serial ports and tons of IO pins. Programmed in C. The dev kit and chip total out at $139 - the chip itself is 12.75.

Other features I'd like to add;

- Remote disable of the car (If the cops arrive at the car and it's moving, I can disable the fuel pump at their request)
- Trigger horn and hazard lights - that should get them out of the car
- Using a car alarm shock sensor add-on ($10 for dual-stange sensitivity) it'll trigger a subroutine if the car suffers a shock when the engine is off. It could detect anything from a break-in to a door ding, and email/SMS my phone.

- There's a couple of other little add-ons I've been wanting to do to my car that required some kind of logic, and I can have these running as independent routines in the processor, such as turning on the hazard lights when it detects heavy braking (determined by a rapid reduction in speed from GPS data) and turning them off again when I accelerate.


THis is all the bells and whisltles, but for now I'd be happy with just the GPS location.

In terms of actually mapping the car, I have an ASP webserver and a microsoft COM object built that handles the modem stuff. Right now it dials into the modem (regualr modem for testing, not the cell modem) and will accept the GPS data back (I have the unplug the GPS until the phone connection is made due to the problem I described earlier with flooding the modem with too much data). The COM object gets all the GPS data in NMEA format and drops everything except the $GPGGA line. Form that it parses out lat, lon and time. Those values are returned to the web page ASP from the COM object using Public Properties and the resulting lat/lon is displayed on the website.

I also launch a seperate browser with a well-formed URL which calls www.mapquest.com and submits the lat and lon in deg/min/sec format - this displays a map with the GPS location pinpointed. So instead of telling the cops "It's at 40d16m40s" I can say "Corner of 3rd and main, heading north at 25mph"

If my car gets stolen I can track it from any internet connection. Work/Home/call a friend etc

I can even make the website compatible with the browser of my recular phone so I can go to a bookmarked website and it'll just display lat/lon/heading/speed so I can call the cops immediately.

I'm gonna go look at the URL you posted now...
 

linuxking

New Member
well the Zilog Z8 Encore MCU has 2 serial ports and the starter kits is pretty cheap too ($49)!

Juz my 2 cents :)

Linux
 

Scruit

New Member
Have you considered buffering the last good GPS signal in your code in case there is no signal when you contact the GTS? If tyhe car is pulled into a building before you contact the GTS then it'll report no signal - but if it buffered the last good signal then it'd report the co-ordinates of outside the building... :wink:
 

Noggin

Member
Yup! Mine constantly buffers :) I've also found that with mine if it looses satellite signal it'll report its last known position every second still. Apparantly the biggest difference with ours is that you're going with a data connection. Can you confirm that with a data connection you are forced onto a TCP/IP network through your cellular provider? That is what I was led to believe, but you never know when talking to someone behind the counter.

There was a senior design group before us that we got our GPS from. They actually used a Rabbit processor, but I wasn't impressed with it at all really (but I didn't learn much about it though either). The ATmega128 is just so ungodly overblown for what we need (16 Mhz and like 128k of program space as well as some flash for semi-permanant storage of phone numbers and security codes) and in bulk its not that expensive.

I didn't think about the horn and hazard lights. I wouldn't think it would be too difficult to add in that capability through a couple diodes and possibly a relay but there is a potential problem that I encountered that you are considering. I'm gonna put it in big bold italics letters just to draw your attention to it.....

DON'T DISABLE THE CAR BY CUTTING THE FUEL!!!! If the car is stolen its likely that whoever is driving it is going to have some fun with it and are dogging the hell out of it. Its not unlikely that their foot will be firmly planted on the gas pedal.... cut fuel to it and there will still be some fuel pressure, but that pressure will drop while you continue to get the same amount of air. This combonation will cause a car to run lean. If it runs too lean, your engine will detonate and can cause MAJOR damage.

I was planning on doing that at first, but now I'm leaning more towards a relay in the steering column to turn off the ignition just as if you turned your key off. I think it would be much less likely to cause detonation since there wouldn't be any spark.

And I'm gonna look at Mapquest for getting a better location.
 

Noggin

Member
Oh yeah, there is also a GPS command to turn off all of the strings. I initialize my UART0 by sending the "shut up" command, I think its "$PGRMO,,0" or "$PGRM0,,0" and then the command to enable the $GPGGA line. If you havn't done this, it might help with your flooding problem. It should be able to handle that much text indefinately.
 

Scruit

New Member
Cool on the disabling data from the GPS - I'll have to check that out!

I actually went with the recommendation above with the Zilog Z8 Encore. The whole dev kit is $49, the chip was $8 and it has more than enough data space and IO pins for my needs. Plus it has two Serial ports, which is perfect.

Other things I'd like to use the IO pins for;

- Horn/Hazard trigger to attract attention if car is stolen (additional beacon for cruisers to home in on) but also if the car is lost in a large parking lot (airport remote parking after you've been away for a week. Where did I leave my car? Pick up my callphone and email an instruction to the server at home, that calls the car and triggers the horn/hazard to help you find it

- Get a couple of those recordable voice chips from Radio Shack and then use the IO pins to trigger them. You can then trigger sounds inside the car like; "This car is being tracked by satellite. Stop and exit the vehicle now."

- Get data from a shock sensor ($10 car alarm add-on) and then compare this shock data with the GPS location. Your can then infer things like parking lot collision, car being towed/flatbedded etc

- Get a cheap 2x24 backlit LCD display to interact with the driver through menus for some functions, like;

- System uses all of it's memory to keep a rotating buffer of the most recent GPS data. That data can then be uploaded to your server at your request. If you are in an accident or get a speeding ticket then you can use the menu to select an option to upload the recent history buffer to your server. Then this data can be used as an impartial witness to your speed/heading/location/time (Assuming this data actually *helps* your case at all, I mean... ;-) ) Speed is frequently a factor and a source of dispute in accidents. So is direction of travel.

- I will hide my system in a hollowed-out factory Center-Brakelight housing in the rear window. My car has a factory spoiler with brakelight - and nobody will think it's out of place.



As far as disabling the car... My background is mostly IT, but some Law and a lot of autmovie electronics/mechanics. I would agree on the lean condition from cutting out the fuel, but I'm not sure the damage would be that bad from a single event... Anyways, that's beside the point because the more important issue is you should never even consider disabling the engine of a moving vehicle. The driver would 'lose' steering (the power assist would stop) and braking assist. The chances of him crashing that vehicle are so great that you or I could be found to have been negligent or reckless in it's design. You could very easily be sued. If not by the felon himself then deinitely by anyone the disabled vehicle crashes into before it can be brought to a stop with 'no' brakes or steering. (I realise that even without assist the steering and bakes still actually work, however the additional effort required is such that an accident is still very likely.

For me I'd say the best thing to do as far as disabling the vehicle would be to put relays on the fuel pump and also the ignition system (12v lead to the coil, coil pack etc). And ONLY disable the vehicle if it is not moving. In an extreme case if you have the police dispatcher on the phone and there are police cruisers that have made contact with you vehicle then you can tell the dispatcher that you have the ability to remotely disable the vehicle if they wish it. If this is the case then the dispatcher will relay to you the appropriate time. This would be at the police's discretion - and on the surface, their liability.

The police have many methods of terminating a pursuit - spike strip, stinger, Precision Immobilisation Turn/Technique, Rolling roadblock etc. If they make the determination that they must stop the vehicle at all costs (or even if they are about the terminate the pursuit for public safety reasons) then the option of disabling the vehicle remotely would present itself. I know a few cops so I'll ask around for their opinions.

Another consideration... My car has individual coil packs per cylinder - I could put relays on three of those cylinders (1 3 and 5 in the firing order) which would allow the vehicle to still run retaining steering and braking functions, but at a dramatically reduced power output - basically only enough to keep the engine running, not drive the car. The police chase scenario woul look like this;

- Car is stolen, you call the police
- You're on the phone with the dispatcher as the unit makes contact with your vehicle based upon your live tracking data
- You inform the dispatcher that you can remotely disable the car in two stages, Stage one will reduce the engine power so the car must slow to a crawl, and the second will shut off the engine.
- The dispatcher communicates with the cruisers and relays back to you instructions to trigger stage one, to force the car to a crawl.
- The dispatcher continues to communicate with the cruisers and then relays back to you instructions to kill the engine.
- Police then have the vehicle stopped in a very controlled manner and they are happy (and there was much rejoicing)
 

Scruit

New Member
How about mounting the rear license plate on a hinge at the bottom and two strong magnets at the top so it stays in place as normal, but one of the IO pins can trigger a solenoid that would push the top of the license plate out, breaking the magnetic hold, and allowing it to hinge down so you can see the back of it...

The back of the place would read; "STOLEN - CALL 911"
 

Noggin

Member
I didn't know how much damage running lean for one instance would cause, but I have seen an online video of a guy running a turbo without any upgrades to the fuel system what-so-ever and it blew his engine to peices, literally. I don't know how long he was running that setup though. However, I'm still not willing to test that on my car, not even at an idle :)

As for crippling the engine before disabling it, thats a good idea. I'm still learning a LOT about the workings of cars, mostly mine (2003 Sentra Spec-V). It uses a direct ignition system (coils on top of the spark plug, no distributor) so I don't know about coil packs.... I assume it has 4 since they are on the plugs themselves... anyway, this is a senior design project for me, I MIGHT keep it for personal use when done.

And I like the idea of the lisence plate folding down, but I don't think many people would even bother to call the police for that UNLESS the alarm and horns were blaring as well as the hazards flashing, but then the lisence plate isn't visible to make a positive ID of the vehicle (almost a minor detail in this case though).

As for the.... crap, i got pulled to something else here at work and forgot what i was saying. Oh yeah, voice.... I also thought about adding in a voice recorder to help with identification if at a trial.
 

Scruit

New Member
Good call on the license plate - didn't think of that. Tell you what I DID think of though... I have a code sample here for scrolling text using the 4 5x7 LED matrixes on the dev board... I could use similar LED matrixes (red ones) and mount them in the 'center brake light' housing that I was already planning to use for my stealth install... I would have a pin on the chip that would listen out for the brake light and light up all the leds on all the matrixes to give a true working center brakelight - and it could also scroll a message when the brakelight is off... I just wonder how close you'd have to be to read it - the letters would be pretty small. The install would be totally stelthy thought - installed inside a *working* center brake light module. Doesn't get much more trick than that.


You have a 2003 Nissan? You have coil-per-cylinder also - that means you only have to interrupt a 12v line (simple relays) to be able indiviudally disable cylinders. Sure, you'd get gasoline in your oil and you probably wanna change your oil after you use this - but if your car *is* stolen then the sudden need for an oil change is the least of your worries. You disable 2 cylinders on a 4-banger (as long as they are 1 and 3 or 2 and 4 in the *firing order* , not necessarily cylinder numbers) then that engine will really have trouble staying alive. That car would be completely crippled. With a 4-pot you can just take out 1 cylinder and the guy will need pedal to the metal just to keep up with traffic.

That Spec-V is a nice car. Good job you're doing the GPS thing... ;)
 

kinjalgp

Active Member
You can multiplex serial port to get any number of ports. See schematic below for a 2-Port multiplexer/demultiplexer. 74LS02 is actually 74HC02.
 

Attachments

  • MUX_176.gif
    MUX_176.gif
    4 KB · Views: 2,156

Scruit

New Member
Hey Noggin,

Here's my progress so far;

I have my old Garmin GPS and cellphone, both data cables, and the Zilog Z8 Encore dev board.

The code is all written and running on the dev board to provide login, logout and locate functions. The website is set up and the COM backend just needs to be tweaked to work with the login/pwd challenge and it'll be ready to go.

So basically the hardware prototype is built and functioning, and I have about an hour's worth of seoftware dev still to do to complete it.


On Monday I'm going on a cross-country roadtrip, driving 1300 miles in a huge truck, so I'll take the prototype with to test it over the 3 or 4 days I'll be driving. I'll also have an automated script dial in and check/record the location every hour.

After the test, if successful, I'll build it into a project box and install it in my car for more testing.

Very close now...

The way it handles buffering is by dropping all but the $GPRMC sentence, and then it checks the latitude field for data. If the field has valid data then it copies the whole sentence verbatim to an output buffer (starting with "$GPRMC"). If the field is empty then it simply resets the first byte of the output buffer to "!" and drops the new GPRMC sentence and leaves the previous sentence in the output buffer.

That means if the GPS location is good, then my website sees "$GPRMC,xx,xxx,xxxx,xxxx" etc. If the GPS has no signal then the website will see "!GPRMC,xx,xxx,xxxx,xxxx". The website will report the position anyways, but if it sees "!" as the first byte then it will display; "No GPS Signal. This is last position as of hh:mm:ss."
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top