Show Posts
|
|
Pages: [1] 2 3
|
|
2
|
Using Arduino / Displays / Re: how do I "convert" text to ASCII for outputting to a display?
|
on: January 02, 2013, 12:35:43 pm
|
|
Both the standard HD44780 LCD displays, and the DL3416 LED displays I'm working with have ASCII to display segment decoders, but that's not what I'm talking about.
So far in my little project, if I want to make the letter A appear on the display, I send the ASCII value 65 - in binary - on a single port that is interfaced in parallel to the display chip. But as I said in my original post, I'm hard coding the ASCII value in the program which is tedious. That's why I started reading the LiquidCrystal library files, because the lcd.print function takes A, and obviously somehow converts it to 65, suitable for outputting the the LCD display.
|
|
|
|
|
3
|
Using Arduino / Displays / Re: how do I "convert" text to ASCII for outputting to a display?
|
on: January 02, 2013, 12:11:16 pm
|
I just can't find it in plain text in any of the files I've opened. That is because it doesn't work like that. ind a "table" in a file that has "A" = 65, "B" = 66, Just think what "A" or to be more accurate 'A' actually is. It is the bit pattern 0100 0001 or to put it into hex 0x41, or if you put it into decimal, which is just silly as far as a computer is concerned it is 65. So 'A' IS 65 there is no need to have a table that says 65 is 65. Somewhere down the line 65 corresponds to several bit patterns that make up the letter A when displayed on a dot matrix. Maybe you will get a better idea if you look up a font generator, like this one:- http://www.lcddesigner.com/english/overview.htmlNormally implemented as a look up table in memory or in a read only memory chip. I know the ASCII table is well established and that the character 'A' was assigned 65 and that it's gospel. But your last sentence is my point. Atmel microcontroller chips don't have an ASCII table in them, and there are no ROM chips on the Arduino boards that could contain such a table that I know of, so the table must be somewhere in a library header file, cpp file, or some file that (when needed) gets dumped in the flash memory at compile/program time. I started in the LiquidCrystal library, and I thought I opened every single file referenced, then opened every other file referenced in those files, etc., but maybe not. Maybe the ASCII table I'm so dying to see is in some low level binary file and I'll never find a plain text, readable file.
|
|
|
|
|
4
|
Using Arduino / Displays / Re: how do I "convert" text to ASCII for outputting to a display?
|
on: January 02, 2013, 11:19:44 am
|
The "magic" you are looking for is in the Print class. If you look at Print.cpp down in {installdir}/hardware/arduino/cores/arduino You will see the print() functions. The Print class functions are inherited by the libraries that use them like HardwareSerial and LiquidCrystal. If you look in LiquidCrystal.h you will see this line: class LiquidCrystal : public Print { That says that all the functions in the Print class will be available to objects in the LiquidCrystal class. Then the real magic is the virtual function write(). When using a LiquidCrystal object function like: lcd.print("hello"); The Print class function print() is called because it was inherited by LiquidCrystal. The Print class code eventually calls the function write() in Print.cpp which really calls the function write() down in the LiquidCrystal code because the write() function is virtual and is mapped to LiquidCrystal write() function. That is how the "conversion" is done. There is no real conversion for text. The Print class pushes out characters one at a time through the write() function. For numbers there is a some conversion from numbers into characters that happens then the same process is used to push out the individual characters. --- bill I don't expect you to find it, but I thought I would eventually find a "table" in a file that has "A" = 65, "B" = 66, etc. I guess it must exist somewhere because there is no algorithm that can magically generate it. After posting about it, thinking, reading, and working on it another 24 hours, it's become apparent it's the only way it can be done. I just can't find it in plain text in any of the files I've opened.
|
|
|
|
|
5
|
Using Arduino / Displays / Re: how do I "convert" text to ASCII for outputting to a display?
|
on: January 02, 2013, 12:09:17 am
|
|
They are Siemens DL3416 17 segment, LED alpha numeric displays, that are long out of production. I have a 1990 Siemens databook that has them, but I didn't find free datasheets on the internet to refer you to.
The timing is not very critical and I can write to them easily, but manually. That's why I was reading the LiquidCrystal library files to see how they did the "text to ASCII conversion". I think I'm making too big of a deal out of this, but I just don't know how it's usually done.
I will have to write my own routines though since the addressing is done differently than the 44780 LCD displays. These LED displays have the usual write and enable signals, plus a 2 bit chip select and a 2 bit digit select. This addressing scheme allows 4 of the 4 digit displays to be used without external decoder chips.
Thanks for the info on how to do it.
|
|
|
|
|
7
|
Using Arduino / Displays / how do I "convert" text to ASCII for outputting to a display?
|
on: January 01, 2013, 10:58:16 pm
|
|
I'm interfacing a Mega2560 to some alpha numeric LED displays, and I've been writing characters to the displays by hard coding their ASCII values in the program.
I want to write a general purpose function similar to lcd.print, but I'm not sure how to "convert" the text to ASCII. Can I just explicitly define all 64 characters like this? #define A 65 #define B 66 ...
I read through all of the LiquidCrystal .h and .cpp files expecting to see how they did it, but I never did find a table or anything.
What's a good way to do this?
|
|
|
|
|
9
|
Development / Other Software Development / request for correction to documentation
|
on: December 31, 2012, 05:57:24 pm
|
On this Arduino web page: http://arduino.cc/en/Reference/BitwiseAnd, about half way down the page you see these two paragraphs. Example Program A common job for the bitwise AND and OR operators is what programmers call Read-Modify-Write on a port. On microcontrollers, a port is an 8 bit number that represents something about the condition of the pins. Writing to a port controls all of the pins at once.
PORTD is a built-in constant that refers to the output states of digital pins 0,1,2,3,4,5,6,7. If there is 1 in an bit position, then that pin is HIGH. (The pins already need to be set to outputs with the pinMode() command.) So if we writePORTD = B00110001; we have made pins 2,3 & 7 HIGH. One slight hitch here is that we may also have changeed the state of Pins 0 & 1, which are used by the Arduino for serial communications so we may have interfered with serial communication.In the second paragraph, this sentence seems wrong: So if we writePORTD = B00110001; we have made pins 2,3 & 7 HIGH. It should say we have made pins 5,4, & 0 HIGH, or else change the binary number to B10001100.
|
|
|
|
|
11
|
Using Arduino / Displays / Re: can you read or write 8 bits at once?
|
on: December 31, 2012, 12:08:11 pm
|
|
I read that all 8 bit binary numbers had been explicitly defined in Arduino and was surprised that they were not "natively" supported in C/C++. But I have a question. I just tried this: int x = B01001100; and the compiler didn't complain. Then I tried adding 8 more bits and it squawked. I guess that makes sense if only the first 256 binary numbers are defined, but doesn't it take 16 bits to be an integer type? Does this mean you can access only the low byte in an integer using binary?
|
|
|
|
|
13
|
Using Arduino / Displays / can you read or write 8 bits at once?
|
on: December 30, 2012, 07:33:01 pm
|
|
I'm trying to interface a Mega2560 to 3 Siemens DL3416 alpha numeric displays. Since there are no libraries written for these displays, I'm trying to learn some details of how things work in the libraries. Being a likely good example, I read through the LiquidCrystal library .cpp file and the .h file, but I'm not seeing what I expected. I confess I'm not real good at any programming language, especially C or C++.
Right now I can do simple things like turn on the cursor in any given character position, so timing is not an issue, but it's very tedious addressing the displays using the bit wise I/O. Is there a way to read or write an entire 8 bit "port" or do I have to shift array values and write a bit at a time? I've searched the forums for bytewise, bytewide, etc., but didn't find the right thread I guess. I'm sure this has been a topic before.
|
|
|
|
|
14
|
Community / Website and Forum / Re: initialize variables inside void setup() or before it?
|
on: December 29, 2012, 12:48:56 pm
|
|
This does not imply this is the only way to initialize variables. If you feel it could be worded better give it a try. Best regards Jantje
I wouldn't word the text differently... I'd just change the example. The text says you can initialize variables in setup(), so I would show a variable being initialized in setup(), not before it.
Thanks, Jim
|
|
|
|
|