We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm using an AT89S8252 Flash eeprom processor. The question I have is getting my case table to to do a char by char comparison. There are multiple user strings, and what I want to happen is for each letter to be compared and when found in the case table, it outputs the corresponding binary/hex value on port 0. Then move to the next char and repeat until the complete word is sent to the decoder with a an adjustable delay between each char send so the decoder blanking doesn't drop chars. Then move on to the next user string and continue this forever.
I've already got most of the frame work but I'm getting three compiler errors, I'm probably missing something petty, its late.....you know that goes. Can someone offer any recommendation as to what I'm missing ?? If more info is needed, just let me know and I can provide more.......here is framework and error:
VFD_DISPLAY.C(217): error C141: syntax error near 'P0'
#include <reg51.h> void Userstring1(); void Userstring2(); void Userstring3(); void DigitDelay(unsigned int time); void ASCII_convert(z); void main() //core system functionality { Userstring1(); Userstring2(); Userstring3(); } void Userstring1() // User string as needed { unsigned char Turbine [] = "Turbine"; unsigned char z; for(z=0;z<7;z++) ASCII_convert(z) P0=ASCII_convert[z]; // <<<<<<<<<<<<<<< Error DigitDelay(1); } void Userstring2() // User string as needed { unsigned char Boost [] = "Boost"; unsigned char z; for(z=0;z<5;z++) ASCII_convert(z) P0=ASCII_convert[z]; // <<<<<<<<<<<<<<< Error DigitDelay(1); } void Userstring3() // User string as needed { unsigned char Validate [] = "Validate"; unsigned char z; for(z=0;z<8;z++) ASCII_convert(z) P0=ASCII_convert[z]; // <<<<<<<<<<<<<<< Error DigitDelay(1); } void DigitDelay(unsigned int time) //digit shifting delay to allow propogation delay transition between characters { unsigned int i,j; for (i=0;i<time;i++) for (j=0;j<1275;j++); } /*===== Case table to convert hex byte to ASCII char generation ========*/ void ASCII_convert(z) { z=z&40; //Set the write line switch(z) { case('@'): { P0=0x00; //Binary value needed to put this char on display break; } case('A'): { P0=0x01; //Binary value needed to put this char on display break; } case('B'): { P0=0x02; //Binary value needed to put this char on display break; } case('C'): { P0=0x03; //Binary value needed to put this char on display break; } } }
Not really sure that such laziness deserves an answer, but ...
Where's the semi-colon at the end of the preceding line(s) - Whoops, there isn't one!
It looks a very cumbersome way of doing it! Why can't you just send the ASCII codes direct?
Anyhow, given
void ASCII_convert(z);
then:
P0 = ASCII_convert[z];
is clearly an error, isn't it?
"what I want to happen is for each letter to be compared"
Letter from where? Compared with what?
Currently, your code does nothing with the strings - it only looks at the index...
"until the complete word is sent to the decoder"
What decoder? How does this "decoder" tell when one character (or index) has finished, and the next starts...?
Your code shows that you have never programmed C before.
I would recommend that tyou stop programming your embedded system, and start program a PC for a while. It normally has more bandwidth for trace output, and better possibilities for a debugger to set an almost infinite number of breakpoints etc.
Besides the comments you have already received: Why separate loops to emit all your strings. Why not a function:
void DisplayString(const char* s,unsigned display_row);
Right now, I get the feeling that you haven't spent any time trying to figure out what you want to do, and the best way to do it. You have just focused on: what are the simplest lines I can implement now that takes me one tiny little step further. Because of this, you haven't figured out a good set of helper functions.
I guess your the only one that thinks your funny......your not.
I did put a semi colon prior and then I get this error:
VFD_DISPLAY.C(217): error C216: subscript on non-array or too many dimensions
Since I was trying to pass the argument to the function was the goal, that just compounded my problem.
I've designed this project from the ground up by hand, telling me I'm lazy is an insult. But thanks for the input anyway
The 8051 is linking up to an ICM7243BIPL which has its own version of binary needed using a 6 bit bus. Since this project is for a friend of mine, I'm trying to make so the only part of the program he has to adjust is typing in the strings he wants displayed to the 14 segment drivers.
So the 8051 must parse each letter, and then convert it to the binary string value in the datasheet character by character with a delay between each character because it requires 300uS between each write and the data is going in sequentially.
I assigned z as the variable I guess I'll have to look at it more closely.
In the case statements, I was sending P0=0x00 because that would be the correct mask needed for the "@" symbol according to the datasheet. It was also late and had already been an all day event.
Each letter in the "" to be compared against the case table and when they match to dump the hex string on the port within the case statement match.
The write bit will be added before each hex string is initiated. So it will be like sbit P0^7 then the hex string then &P0^7
I've designed this project from the ground up by hand
Most of us are designing our projects by hand. Application generators are so seldoom available and/or able to solve embedded problems.
...requires 300uS between...
Note that uS does not mean what you believe. S is the SI unit for Siemens, i.e. it represents conductance. In this case, 300uS is the same as 3.3 kohm. If talking about a time delay, you should write 300us. Upper or lower case on characters is always important in programming and in science.
...which has its own version of binary needed using a 6 bit bus...
6 bits represents 64 characters. Is it a continuous sequence, i.e. '@' and the next 63 characters? In that case, you don't need any huge switch statement. Just do:
if (c < '@' || c >= '@' + 64) c = MAPPING_FOR_INVALID_CHARACTER; else c -= '@';
If it isn't a continuous sequence, it would still be better to have a translation table:
unsigned char table[] = { 0,10,7,14,13,...}; if (c < ' ' || c > 'z') c = '?'; c = char_table[c - ' '];
Yep sorry for the confusion, should have been "us" for time.
The binary bitstream is continous and each binary value is connected to an ASCII symbol based on the 7243 character mask. I don't think this forum allows images, so I posted the IC and the char set so you can see what I'm trying to acheive.
I agree that my code is large and unwieldy, but I have pass this off to someone is not programming capable and he has to be able to modify and compile it 3000 miles away.
I'm going to create a screenshot video to show him how to do it, and I'm trying to keep everything as modular as possible. Since this project only function is to display programmed strings, it doesn't have to be 'guru" certified since its a single task of writing a string on a display.
Hopefully the images help.....thanks again for giving me a hand
www.kittmaster.com/.../SS001.png www.kittmaster.com/.../SS002.png
"The binary bitstream is continous and each binary value is connected to an ASCII symbol based on the 7243 character mask."
All you need to do is AND the ASCII character value with 0x3F and write the result to the port.
"I agree that my code is large and unwieldy, but I have pass this off to someone is not programming capable and he has to be able to modify and compile it 3000 miles away."
Which sounds like exactly the reason that your code should be clear and simple - not large and unwieldy!
LOL...
I don't code everyday, just the way it is. I'm sure in hind sight you'd say the same about your past. Most of my skills are within assembly, but he wants it in C. Live and learn I guess.
its late.....you know that goes. Can someone offer any recommendation as to what I'm missing ??
Not intended to be funny!
In my opinion, your original sentence was is a classic sign of laziness!
Hi Dan,
This was the most helpful answer I got and bingo it worked as I wanted it. I didn't think to take the ascii table values and then AND them with the matrix size and it works perfectly. Thank you!
To everyone else, thanks for offering up advise and guidance.
Regards, Chris
Here is the end result:
#include <reg51.h> void main(void) { while(1) { /// Copy this block and repeat { unsigned char string1[]="TURBINE"; unsigned char z; for (z=0;z<=7;z++) P0= 0x3F & string1[z]; } /// End copy block and paste below just bore the "Do Not edit below this line comment, be sure in include the {} braces!!! { unsigned char string1[]="BOOST"; unsigned char z; for (z=0;z<=5;z++) P0= 0x3F & string1[z]; } { unsigned char string1[]="VALIDATE"; unsigned char z; for (z=0;z<=8;z++) P0= 0x3F & string1[z]; } { unsigned char string1[]="SENSOR"; unsigned char z; for (z=0;z<=6;z++) P0= 0x3F & string1[z]; } // ========Do Not edit below this line ============= } }
And that is supposed to help someone how exactly?
Whatever dude....you'll someday be somewhere your not on that high and might perch.....
Thanks anyway, I did get a good laugh out of your <in my opinion> condescending attitude.....peace