6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 29, 2024 7:30 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: new simple 6502 project
PostPosted: Tue Oct 19, 2004 12:19 am 
Offline

Joined: Tue Oct 19, 2004 12:10 am
Posts: 3
Location: Dallas, Tx
I'm looking at building a 6502 based transmission controller for an automotive project. I've got the code written and it runs fine on my emulator of choice (NES :lol: ) but I have no idea on where to begin on putting the hardware together.

Basically it requires 3 binary inputs (2 momentary pushbuttons, 1 toggle switch) and 4 binary outputs along with an LCD display to show what gear it is in.

I have found several examples on the 6502.org projects list that had LCD displays, but none that used on off switches for inputs.

If anyone knows of some documented example, or can give me a brief discription as to how I'd do that it would help out with my project greatly

I am not a hardware guy, so I'm sorry if this is too much of a newbie question for you all.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 19, 2004 1:25 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
You can do all the I/O with a single 6522 VIA. For any given switch line, connect the switch from the I/O line to ground, and a 10K resistor from the line to +5V. When the button is not pressed (or the toggle switch is open), the port will read a logic 1 for that bit. When the switch is closed, the port will read a logic 0.

To set up the VIA, write to DDRA (data direction register for port A) and DDRB (same, for port B) with a 1 in each bit that you want for an output and a 0 in each bit you want for an input. After that you can read and write the ports directly. Port pins that are set to be inputs will not be affected by a write to the port.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 19, 2004 5:32 am 
Offline

Joined: Tue Oct 19, 2004 12:10 am
Posts: 3
Location: Dallas, Tx
thanks, I'm new to most of this but after searching I think I know what your talking about :lol:

I haven't seen any code examples that read from a binary input, but is it safe to assume I just read instead of writing to get input from the same address?


whats the best way to get a 1 digit LED display to show a number, and if I later wanted to add a character LED how would that work?

Guess I really need to start getting these parts and experimenting.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 19, 2004 7:31 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
> I haven't seen any code examples that read from a binary input, but is it safe to assume
> I just read instead of writing to get input from the same address?

Your source code should have the VIA addresses something like:

Code:
VIA:  EQU $6000  ; VIA base addr (Depends on your hardware)
PB:   EQU VIA+0  ; port B I/O
PA:   EQU VIA+1  ; port A I/O
DDRB: EQU VIA+2  ; data direction register for port B
DDRA: EQU VIA+3  ; data direction register for port A
T1CL: EQU VIA+4  ; timer 1 counter low byte
T1CH:            ; etc etc
T1LL:
T1LH:
...

To write to port B's output bits, just write to PB (which will be address 6000 in the case above). Input bits will remain unaffected by the write as long as they're left in input mode. To read port B (all 8 bits, whether input or output), just read PB (same address). Same goes for port A. There are several ways to deal with what you read, including (but not limited to) the following. To look at only certain bits after reading the port, you can AND-out the ones you don't want, or use the TSB or TRB instructions. You can shift or rotate and then branch on the carry flag, or (less likely) use the bit pattern as an index in a jump address table.


> whats the best way to get a 1 digit LED display to show a number, and
> if I later wanted to add a character LED how would that work?

Hardwarewise, the LCD is actually easier. LEDs will take a lot more output bits, and if you have very many digits, you'll want to multiplex it which will require constant strobing. For just one digit, you'll connect the common to ground (if common cathode) or to +5V (if common anode) and then connect each segment's pin through a resistor of say 470 ohms to an output pin of the VIA. If you get a lot of digits and you're not multiplexing the display, you'll do the least wiring work and the lowest bus loading if you use the VIA's shift register to feed a chain of 74HC595's. You could use 74HC164's too, but they don't have output latches, so all shifting is reflected at the outputs during actual shifting. With the shift register chain, you only use 2-3 pins of the VIA, and the software only pays attention to it when you're giving the display new information. That way it does not require the constant strobing. Maxim www.maxim-ic.com does have a variety of LED driver ICs you might want to look into too. They have a serial input, all the current limiters, and take care of the strobing in multiplexed LED arrays too so you don't have to worry about that. They will have onboard character-gerator ROM too so your software doesn't have to look up which segments to light up.


> Guess I really need to start getting these parts and experimenting.

Beginners tend to do everything the hard way. Keep coming back to the forum and you should be able to save yourself some headaches. I "paid my dues" in the mid 80's. My first computer had an 8-digit non-multiplexed LED display. The wiring with the 8 shift registers and 64 current-limiting resistors (7 segments plus decimal point for each digit) was sure impressive, but the display was big, power-hungry, and not nearly as versatile and useful as a simple 16-character by 1-line LCD module. 7-segment displays can do either upper- or lower-case of most of the characters, but it's sure not user-friendly when you have to do things like make W to be an up-side-down A or figure out how to differentiate K from X.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 19, 2004 1:49 pm 
Offline

Joined: Tue Mar 09, 2004 3:43 pm
Posts: 44
Location: Bristol, UK
Just a word of caution about automotive electronics; the car's electrical system is a hazardous place for electronics. I was helping a friend at the weekend with a very simple circuit for intermittent wipers. She's built it from a Velleman kit, and intends to fit it in her Morris Minor. It worked fine on the bench, clicking the relay in and out every few seconds under the control of a simple 555 timer chip. It worked in the car, too, until she connected the wiper motor to the relay contacts when the 555 chip blew instantly. We think it's due to a voltage spike on the 12V power supply when the motor is switched off. But so far, no cure.

So, just wanted you to know that you'll need to protect your circuit from the hazards of the in-car environment. That means physical protection from heat and water, as well as electrical protection on power supplies and I/O connections.


Top
 Profile  
Reply with quote  
 Post subject: Automotive CPUs
PostPosted: Wed Oct 20, 2004 9:51 am 
Offline

Joined: Wed Mar 24, 2004 10:54 am
Posts: 38
Just though I'd scond that!

In the early 90's I worked on an on-board vehicle weighing system for articulated trucks and refuse vehicles ("council shit carts" to give them their more poplular name! - ever seen how to open a set of council garage doors in one easy go? Ask me sometime!). It was a relatively humble 65C02 based system (couldn't persuade the boss to invest in the stuff to move over to 8051 at the time, but that's another story) using strain bridges, CAZ amps and in-house designed inclinometers. For the AD section (cheapskates that we were) we used an ICL7135 DVM chip with multiplexed BCD outputs. Slow but accurate and only £15 at the time - compared to truck loads of dosh for anything over 10-bit accuracy.

Anyway, trying to run anything electronic from a vehicle power supply is no joke. You need serious amounts of smoothing - and that's just on the input to ensure the main voltage regulator doesn't go berzerk! You basically have to forget about it being a 12v DC supply (or 24v in the case of most trucks) and instead treat it as you would a very noisy unregulated AC supply from a crap transformer wih very poor regulation.

Expect very large and frequent spikes, deep sags and noise like you wouldn't believe..... And of course don't forget the die-cast box to put it all in remembering that anything you bolt it to will be connected, usually, to the -VE battery terminal and thus so will your box!.

Happy going!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 20, 2004 5:31 pm 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
Since we started in 1992, all of our products for private aircraft except the most power-hungry one start the power out with an LM317T or LM350T regulator which can handle at least 40V above the input voltage. Many other regulators can handle that much without damage but will shut down to protect themselves until the input voltage returns to the acceptable range. We don't accept that. It has to keep right on working through such spikes. We have many thousands of these flying all over the world, and we do not have power supply problems. The 5V digital portions also keep working without a hitch. The aircraft have 12V and 24V systems. Just figure that a 12V system's regulator may be as much as 4V high, not including ripple and spikes. If the engine is not running and the battery is low (as when testing things in the hangar), the voltage may easily be 11V, again with noise on it from other equipment. As for grounds, we have signal inputs and outputs all over the cabin but we don't let any of them get their ground connections through the airframe. All the grounds come back to the intercom, which in turn is grounded at the radio(s), which in turn are grounded to the airframe. That way the signals are all clean and free of unwanted noises from alternators, gyros, strobes, etc., even though small-aircraft electrical systems are notoriously poorly designed from an electrical noise standpoint. It's not hard to make it all work right. Just start with the mentality that the power is all over the place and incredibly noisy.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 20, 2004 6:49 pm 
Offline

Joined: Tue Oct 19, 2004 12:10 am
Posts: 3
Location: Dallas, Tx
I'm also trying to do this project cheap, so I'm reusing a bunch of parts I've got sitting around.

For the power supply, I'm going to get them off a 88-91 GM efi computer since I've got a few sitting around. They use some form of motorola chip running at 5vdc and I've never had one of those go bad.

coredump I'm not familiar with Morris, only English vehicle I've worked on is a Discovery. If there are as many Lucas parts in a Morris as there are in a Rover I could certainly see some problems showing up :lol:


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 06, 2005 2:36 pm 
Offline

Joined: Fri May 06, 2005 1:02 pm
Posts: 17
Location: Limerick, PA
If you're not stuck on using an LCD for the display, you could simplify your design just by using a 4511 BCD to 7-segment display decoder (since you're going from 1 to 4 or 5, with a possiblity of R) The LCD may be a little bit of overkill for your application.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: