Shift register help please.....

I'm Ash from Malaysia.
let me talk about it a bit before i ask my question

back when i was a PLC programmer, I use to make program for machine(we call that module) that have multiple sub station.
let me give you an example of how a module work Urm maybe a Bottle Packaging Machine would be a great example.
lets say that this module have 4 sub station
1)Filling the water
2)Capping the bottle
3)Labeling the bottle
4)Sorting to boxes.

Anyway before each substation there is a check whether there is work to be done or not by means of sensor or simple programming logic. and at the very end of each substation there is a reject bin where as all the product that are deem inferior is being throw out of the assembly line.

so while we are programming for PLC, there is a fuction that are call Shift register,
usually a shift register could be an 8bit or 16bit or 32bit or we could even specify how many bit that we need for the machine.

the function of this shift register is to carry the information whether the machine should do anything to the product or not, well that is base on the logic.

so my question is for this post are,

  1. is there any way to implement an internal shift register, as i only being able to find in the net all about shift register IC.
  2. if there is, please teach me how to use the internal shift register and how i use individual bit to carry certain information?

A shift register could also be termed a FIFO.
Useful search term there.

I'm Ash from Malaysia.

Yes, we know, you keep telling us.

is there any way to implement an internal shift register,

Yes but it is not called a shift register. You simply do it with code. A circular buffer is what is required, you can code it to be as long as you like.

Hay sorry mate, Is how we interact here in malaysia, when talking to someone we dont know... really or is it just me.?????

No, I think it is just you.
Besides, it's right there on the left, under your name.

ok ok i will drop the Hi I'm ash from malaysia stuff after this,

anyway how could i implement this FIFO or Circular Buffer?

what i want is something like this

address 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7
bit 1 0 0 1 1 1 0 1

where as i have something that could trigger the shift in this case shift to the left

address 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7
bit 0 1 0 0 1 1 1 0

and one to give signal 1 or 0 with the stepping of the shift

so lets say that i need the information form maybe address 10.3 with some other logic, i could easily use if (10.3 && 6) {then something happen}

I don’t understand your decimal addresses.
With a circular buffer, you don’t move any data, you just change the pointer(s).
If you’re only moving bits, you could use an integer variable of sufficient size, and use the “<<” or “>>” operators, testing the bits of interest with a mask.

the decimal adress is something that PLC use, its something that i use to show the concept but the addrees it self is non critical.
could you point me to a good tutorial about the pointer and mask that u said awol?
i saw this while reserching for a while but really dont understand what it means.

could i use shift bit and bit read as to accomplish what i ask?

If you don't need anything other than ones and zeroes, and you don't need a "shift register" bigger than 64 (though smaller would be better), yes, very easily.

is lets say i want to declare do i need to use int or could i just use uint8_t?
lets say that i have a button and state that toggle every 10 second,
i want to use that button to set the MSB to one and only when the state is high will the bit shift to the left 1 spot.
then i want to use each bit to control a row of LED, my guess is maybe 8 LED?

this is only a mock up of what i may know please correct me if im wrong
int/uint8_t a=00000000;
inside loop something like
button ? bitWrite(a,8/or is it 7?,1):bitWrite(a,8/or is it 7?,0)
if state high then a=a>>1;

digitalWrite (led1,bitRead(a,0/1);
and so on

is my logic correct?

and only when the state is high will the bit shift to the left 1 spot


I think you have your left and right mixed-up.

Yes, the most significant bit of a byte is bit 7.
To avoid premature hair-loss, I suggest you stick with unsigned types.

i mean shift to the right 1 spot.
i think shift to the left would be easier...
urm well thanks awol, i will try to impliment what i need today in my future project.

button ? bitWrite(a,8/or is it 7?,1):bitWrite(a,8/or is it 7?,0)

Could be abbreviated to bitWrite(a, 7, button ? 1 : 0);

thanks again Awol, Im testing it with 8 LED as we speak

so my question is for this post are,

A shift register here could just be a variable of appropriate length.

I think that's already been established, thank you, dhenry.