Ok, so im attemping to completely redo my gauges in my car and want to put blue seven segment displays to display my fuel level, temp, oil pres, tach, and speed. I ordered a Pro mini and a MC14489 to control the segment displays, I have looked over the datasheet and read post of others implementing in the Basic Stamp which i am familiar with. But to the point I came to the conclusion that it would be easier to use the shiftOut() command in Arduino but it shifts out a byte at a time and the chip uses 1 byte for configuration: dp, brightness, etc. Then it takes 3 bytes to display numbers but the numbers or "digits" are in Nibble packets. If anyone has any idea how i can atleast get some digits displaying it would be greatly appreaciated.
Then it takes 3 bytes to display numbers but the numbers or "digits" are in Nibble packets.
There are two nibbles in a byte. Set up the value for the high nibble, shift it 4 positions to the left, and add the low nibble, to get a byte.
Post a link to the device you are trying to "interfact" with, for more help.
heres the datasheet link...........RasMicro.com is for sale | HugeDomains
if it makes any relation I'm using the DIP package.
I finally got it to display a given number but now when i get it to count it does the digits but also letters which tells me its interpreting as hex and I cant use that. If anyone has ideas or knows how to count and display just numbers I sure would appreciate it. Here is the code i have so far, its kinda sloppy and not comment but hope it can still help.
int datapin = 10; // Data out on the arduino
int enable = 11; //enable latch for mc14489, LOW active
int clock = 12; //clock pin
int blank = 0x01; // config byte, last bit is high to put in normal mode
int byte1 = 0x000; //byte 1 of 3, first 4 bits control the decimal point and last 4 control digit 5 which is irrelavant to me
int byte2 = 0x000; //byte 2 of 3, first 4 bits control digit 4 and last 4 bits control digit 3 which I need
int byte3 = 0x000; //byte 3 of 3, first 4 bits control digit 2 and then last 4 bits control digit 1 which I need both
void setup() {
pinMode(datapin, OUTPUT);
pinMode(enable, OUTPUT);
pinMode(clock, OUTPUT);
digitalWrite(enable, LOW);
shiftOut(datapin, clock, MSBFIRST, blank);
digitalWrite(enable, HIGH);
delay(100);
}
void loop() {
digitalWrite(enable, LOW); //this segment sends the first byte to config the display register
shiftOut(datapin, clock, MSBFIRST, blank);
digitalWrite(enable, HIGH);
delay(100);
digitalWrite(enable, HIGH);
shiftOut(datapin, clock, MSBFIRST, byte1); //this part updates the digits and decimal
shiftOut(datapin, clock, MSBFIRST, byte2);
shiftOut(datapin, clock, MSBFIRST, byte3);
digitalWrite(enable, HIGH);
byte3 = byte1 ++
}
but now when i get it to count it does the digits but also letters which tells me its interpreting as hex and I cant use that.
So, now you need to smartly assign values to byte1, byte2, and byte3. The comments tell me that you know what to put in each byte to make a given number appear.
So, in loop(), assign a meaningful value to each nibble of each byte. I'd create a function to set the high or low nibble to a specific value, and call that function 6 times for each value to display. The key is to know what happens when you send 0x0 to 0xF as each nibble.
Make a chart and 6 for loops in setup(). Leave loop() empty.
In the for loops, set 5 nibbles to 0 and the 6th to 0x0 to 0xF. For each iteration of each loop, record what appears on the display. This will give you a chart that lets you set all 6 nibbles to control what appears on the display.
ok so with some trial and error i finally got it to count from 0 to 9 then shift places....essentially counting in base 10. now my delima is being able to take a analog reading and converting that or splitting up the number and turning it into nibbles to display I would really like to see 0 to 255 as my min/max. I'll post my code if will help in being able to simplify things...
int data = 10;
int enable = 11;
int clock = 12;
int blank = 0x01;
int byte1 = 0x00;
int nib1 = 0;
int nib2 = 0;
int nib3 = 0;
int nib4 = 0;
byte(byte2);
byte(byte3);
void setup(){
pinMode(data, OUTPUT);
pinMode(enable, OUTPUT);
pinMode(clock, OUTPUT);
}
void loop() {
digitalWrite(enable, LOW);
shiftOut(data, clock, MSBFIRST, blank);
digitalWrite(enable, HIGH);
delay(10);
nib4 = nib4 ++;
if(nib4 > 9) {
nib4 = 0; nib3 = nib3 ++;
}
if(nib3 > 9){
nib3 = 0; nib2 = nib2 ++;
}
if(nib2 > 9) {
nib2 = 0 ; nib3 = 0; nib4 = 0;
}
byte3 = nib3 << 4 | nib4;
byte2 = nib1 << 4 | nib2;
digitalWrite(enable, LOW);
shiftOut(data, clock, MSBFIRST, byte1);
shiftOut(data, clock, MSBFIRST, byte2);
shiftOut(data, clock, MSBFIRST, byte3);
digitalWrite(enable, HIGH);
}
nib4 = nib4 ++;
The code
nib4++;
means
nib4 = nib4 + 1;
So, your statement means
nib4 = nib4 = nib4 + 1;
Is that really necessary?
ok so with some trial and error i finally got it to count from 0 to 9 then shift places....essentially counting in base 10.
So, nib4 = 0, nib3 = 3, nib2 = 1, and nib 1 = 0 causes 0130 to appear?
If you can set a nibble to a specific value, like 4, and that value appears in the nibble number's (nib3 = 4 causes a 4 in the 3rd position) position on the matrix, then the only issue is how to set the nibbles based on the value in an int, right?
So,
nib1 = value % 1000;
value -= nib1 * 1000;
nib2 = value % 100;
value -= nib2 * 100;
nib3 = value % 10;
value -= nib3 * 10;
nib4 = value;
I'm late to the game but I made a library for this because I have been using this display a lot, and it has really shortened my code down!
I loosely based it on your program for sending the bits of information.
https://code.google.com/p/mc14489-seven-segment-display-driver/
The reason I'm using the MC14489 is because I used to have a DIY gauge in my car and it used this system, so I have a seven segment display and a MC14489 already connected, so I figure I would teach myself to use it.
This is my first library and I just got my arduino last week so I have been messing around a lot.