bit train read in

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

atmega 32

AS7

 

i want to read in 300 bits on 1 input (serieel) with using a clock pulse. i want to store this.

0,1 sec later i have to do this again.... and again... and again for 300 times.

so i receive 300x300 = 90 000 bits.

what is the most easy way to do this ?

 

i already did some homework of course, and i found a way to store a single bit in a array, the problem is that you normal not can use a single bit in a array.

but whit this trick it was posible, and i save it in my favorites (google)

and then.....my laptop crashed so my favorites in google are gone angry

 

but i already used a part of the code in a program (not tested) so maybe some one wil recognize this trick ?

with the same trick it was also possible to read out a single bit.

 

just for your information, what i finally want to gonna do whit the bitmap:  you can imaging, this wil gif a bit map from 300x300 bits. in this bitmap you can see the shape from (for example) the letter E. later i wil gonna draw this letter whit a marker on paper. (steppermotors).

 

thanks in advance for your help, and i like to wish every one a happy and healthy 2019.

 

int colum [300];  

   int colnum = scan/32;           // i = array index (use: A[i])
   int pos = scan%32;              // pos = bit position in A[i]
   unsigned int flag = 1;          // flag = 0000.....00001
   flag = flag << pos;             // flag = 0000...010...000   (shifted k positions)
   A[colnum] = A[colnum] | flag;   // Set the bit at the k-th position in A[i]

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know why you call it a 'trick' as it is common practice in embedded systems.


uint8_t column[38];     //38 * 8 bits = 304 bits
const uint8_t masks[1,2,4,8,16,32,64,128];

int bitcount = 0;

void add_bit(bool bit)
{
    if (bit)
        {
        column[bitcount>>3] |= masks[bitcount & 7];
        }
    bitcount++;
}

or something similar. The AVR is an 8bit machine, so do the operations on 8 bit values. The AVR doesn't have a barrel shifter, so shifts are done one at a time. This is why I use a lookup table

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

because its sounds mysterious wink

 

i gonna see or i understand your code......thnx

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you plan to do with this almost 12k bytes of info?

Where will you store it, most AVR's only have 1 or 2k of ram memory?

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

your right,

i,m using now for the moment a Atmega 32 to test some things,

later i want to use a Atmega1284 who has  16K Bytes Internal SRAM. but i have a lot of problems to prog this one see also:

https://www.avrfreaks.net/forum/dragon-does-not-atmega1284p?skey=trixo

 

because i don,t want to lose a lot of time with the programming issues so i already start with some program testing.

Last Edited: Wed. Dec 26, 2018 - 01:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When using the UsART or SPI to read in serial data it is already chopped in byte size pieces by the hardware.

UsART does not work for a continuous stream ut SPI might.

 

Or just shift 8 bits into a bye before you store it.

Or if it fits your data well you could use some form of run length compression.

https://en.wikipedia.org/wiki/Run-length_encoding

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i,am just checking SPI in the data sheet, and i think this is gonna work.

its a litle bit complex for now, because the explane every thing, but i need a litle bit of it.

just 38 bytes (300/8) shifting from one to the other Atmega, how hard can it be ???

 

for now, every body thnx for your help

 

Last Edited: Wed. Dec 26, 2018 - 08:22 PM