Author Topic: Does sending a letter take the same time as a number?  (Read 1239 times)

dave_sausages

  • Newbie
  • *
  • Posts: 49
Does sending a letter take the same time as a number?
« on: January 09, 2017, 08:18:32 PM »
So I'm trying to reduce the power consumption of my project and also the time the radio is sending data, and as part of this I'm now just sending codes for different thing: 0=on 1=off 2=off but waiting for signal etc, instead of long strings for each piece of data. So by just sending one character I can communicate 10 different options.

However I'm now running out of numbers, and was wondering if I can also start using letters to allow me to send 36 different options (26 letters+10 numbers) while only having to transmit one character? otherwise I'll have to start using two numbers back to back.

So does my LoRa Moteino take the same time to transmit a letter as it does a number?

Cheers

ChemE

  • Sr. Member
  • ****
  • Posts: 402
  • Country: us
Re: Does sending a letter take the same time as a number?
« Reply #1 on: January 09, 2017, 08:31:43 PM »
It should be the case that a single letter is a byte and so too is a number between 0 and 255 (or -127 and 128).  You can actually stuff quite a lot into a byte but the radio will spend exactly as much time actually transmitting regardless of whether it is a byte which represents a number or a byte which represents a character; it is still 8 bits.
« Last Edit: January 09, 2017, 09:33:52 PM by ChemE »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5905
  • Country: us
    • LowPowerLab
Re: Does sending a letter take the same time as a number?
« Reply #2 on: January 10, 2017, 08:59:31 AM »
Yes, as long as each character is a byte (ASCII), which is what these basic libraries allow you to do.

ChemE

  • Sr. Member
  • ****
  • Posts: 402
  • Country: us
Re: Does sending a letter take the same time as a number?
« Reply #3 on: January 10, 2017, 11:30:41 AM »
If you are okay with 32 options rather than 36, you can actually stuff two options into a single byte.  Use the upper four bits for one option and the lower four bits for the second.  If you really want to keep your broadcasts as compact as possible, you'll need to turn off CRC since it requires that the payload be 16 bytes long even if you don't need/want to transmit that much.  CRC is on by default.

More reading here: https://lowpowerlab.com/forum/rf-range-antennas-rfm69-library/send-waaay-fewer-packets/
My 300kbps settings with no CRC here: https://lowpowerlab.com/forum/rf-range-antennas-rfm69-library/changing-the-rmf69hcw-configuration-and-back/msg17071/#msg17071

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5905
  • Country: us
    • LowPowerLab
Re: Does sending a letter take the same time as a number?
« Reply #4 on: January 10, 2017, 11:39:38 AM »
ChemE is right.
What is a byte actually? It's 8 bits, 1s and 0s. With that combination you get 2^8 combinations, ie 256. The ASCII table is a standard which assigns 256 characters to these combinations. So each combination means a character from that table. If both ends agree to this standard, then both ends know what combination means what character.
You can always interpret a byte differently and make your own table with fewer combinations, like ChemE said, you could split that byte in 2 perhaps and have each set of 4 bits yield a separate "character" whatever that would mean.

perky

  • Hero Member
  • *****
  • Posts: 871
  • Country: gb
Re: Does sending a letter take the same time as a number?
« Reply #5 on: January 10, 2017, 08:25:04 PM »
If you really want to keep your broadcasts as compact as possible, you'll need to turn off CRC since it requires that the payload be 16 bytes long even if you don't need/want to transmit that much.  CRC is on by default.
I think you're getting confused with encryption, CRC simply adds two bytes to the end of a packet during transmission and allows the radio itself to check the CRC during reception.
Mark.

ChemE

  • Sr. Member
  • ****
  • Posts: 402
  • Country: us
Re: Does sending a letter take the same time as a number?
« Reply #6 on: January 11, 2017, 07:50:59 AM »
I think you're getting confused with encryption, CRC simply adds two bytes to the end of a packet during transmission and allows the radio itself to check the CRC during reception.
Mark.

My bad, you are correct.  Still CRC adds two bytes to the frame and for very short frames and lower BER, a parity bit may be all that is needed as opposed to a 16-bit CRC.  I'm still playing with different schemes but my TH node is using a 4 byte payload which houses Temp/RH/Vcc/Target node and a parity bit (1-bit CRC).  Add 2 preamble bytes and a sync byte and you've got a 7 byte transmission.

EDIT: Oops, make that 5 bytes for a payload.  I made a mental error in thinking I could fit battery voltage into 4 bits, it takes 7 bits to capture 3.3 to 2.3 VDC.  An eighth bit would capture down to 1.8V but the radio will have died at 2.4V so there is not any point giving it an eighth bit.  The scheme is simple enough: the node takes a battery voltage reading and rather than convert the raw value to a voltagex1000, just subtract a fixed quantity from the raw reading.  For me it is 345 but depending on your batteries it will vary.  As voltage drops over time, this raw value climbs.  7 bits can capture 1089495/(345+0) to 1089495/(345+128) = 3.157 to 2.303 volts.
« Last Edit: January 11, 2017, 08:56:04 AM by ChemE »