PDA

View Full Version : Writing to a table.



Rhatidbwoy
- 22nd December 2005, 21:45
I have 48 hex bytes of data that I would like to write to a table. I have played with the lookup2 and lookdown2 that the PBP has to offer and continuing with the thought of how to write to a table I am stumped. Reading from the table is not bad, I do not have a problem with that, it is trying to write to one.

Looking at my program what I am trying to do it find the position of what I want to write to on my table, example: position 1, and write to it rather than write to a value. I review to what I have I might just be writing to a number/constant.

The program is attached and the part that I am talking about is Labeled CHNL. If anyone has help to this problem I would appreciate it.

Rhatidbwoy
- 23rd December 2005, 03:07
The prog that i have attached to this is something that I am looking at wanting to do. Is there anything that anyone might have for suggestions.

Thanks

Luciano
- 23rd December 2005, 18:33
Hi,

I understand that with the PIC16F648 you control the
configuration of the 7 Control channels of a radio control (R/C).

For each of the 7 control channels you have the following parameters:

- Servo Reversing (1 byte)

- Variable Dual Rate (3 bytes)

- Adjustable Travel Volume (3 bytes)

These parameters are stored in the EEPROM of the PIC.
For each control channel you use 7 bytes of EEPROM.
In total 49 bytes are used in the EEPROM.

Store the values in the EEPROM as data blocks.
Each block of data will contain the 7 bytes necessary
to store the parameters of a channel. We will call
these data blocks RECORDS. Below you can see the
map of your EEPROM. The first 7 bytes (0-6) of the
EEPROM are not used and are available for other uses.

* * *

EEPROM map

Where:

X= Not used
R= Servo Reversing (1 byte)
DDD= Dual Rates (3 bytes)
TTT= Travel Volume (3 bytes)

REC 0 REC 1 REC 2 REC 3 REC 4 REC 5 REC 6 REC 7
DUMMY (CH1) (CH2) (CH3) (CH4) (CH5) (CH6) (CH7)
_______-------_______-------_______-------_______-------
XXXXXXXrdddtttRDDDTTTrdddtttRDDDTTTrdddtttRDDDTTTr dddttt
01234567891111111111222222222233333333334444444444 555555 (EE Address)
0123456789012345678901234567890123456789012345


To find out the record address for the selected channel:
(You know the channel number because you have selected it on the LCD).

record_address = channel_number * 7

Once you have calculated the record address:
(The address of the first byte of the record).

------------------------------------------

To read the Servo Reversing byte from the EEPROM:

READ record_address, servo_reversing

------------------------------------------

To read the Dual Rate first byte from the EEPROM:

READ record_address + 1, dual_rate_b1

To read the Dual Rate second byte from the EEPROM:

READ record_address + 2, dual_rate_b2

To read the Dual Rate third byte from the EEPROM:

READ record_address + 3, dual_rate_b3

------------------------------------------

To read the Travel Volume first byte from the EEPROM:

READ record_address + 4, travel_volume_b1

To read the Travel Volume second byte from the EEPROM:

READ record_address + 5, travel_volume_b2

To read the Travel Volume third byte from the EEPROM:

READ record_address + 6, travel_volume_b3

------------------------------------------

Below are the variables in RAM.
These variables are used as temporary storage and their
content will change based on the selected channel number.

channel_number
record_address
servo_reversing
dual_rate_b1
dual_rate_b2
dual_rate_b3
travel_volume_b1
travel_volume_b2
travel_volume_b3


Do the same to WRITE to the EEPROM.


Best regards,


Luciano

Rhatidbwoy
- 23rd December 2005, 21:00
took a little time to come with it huh. I like it. I will have to sit down and look at it several time to learn what you did. I can say that I understand and follow it, but to truly I learn something, I will have to sit and read. Thanks man.

Rhatidbwoy
- 24th December 2005, 16:20
it is wonderful. I reviewed it and made sense of it. It is the table I was really looking for. What is does is to transform a table into more so the equation and it does work. Thanks!