How to check signal change over time

Thread Starter

@vajra

Joined May 2, 2018
154
I use 8051 /raspberry and C / python programming.

I want to check signal change over time

ie. One signal come to pin of microcontroller that can be 5v or 0V. I just want to read that signal over time

I need help to implement the program. What logic needs to develop the program?
 

LesJones

Joined Jan 8, 2017
4,190
You will need to define what you want more clearly. Do you need to monitor the analogue value of the signal or just it's state ? (0 or 1) How frequently do you need to sample the signal or do you just need to record changes of state ? Over what length of time do you want to record the data ? (So the total amount of data is known.)

Les.
 

Thread Starter

@vajra

Joined May 2, 2018
154
You will need to define what you want more clearly. Do you need to monitor the analogue value of the signal or just it's state ? (0 or 1) How frequently do you need to sample the signal or do you just need to record changes of state ? Over what length of time do you want to record the data ? (So the total amount of data is known.)

Les.
I just need to record changes of state for 5 minutes
 

Sensacell

Joined Jun 19, 2012
3,453
To what level of timing precision?

How to save / read / use the resulting data?

Think this through, you must understand that specifications are at least 30% of the job.
 

LesJones

Joined Jan 8, 2017
4,190
I have used the interrupt on change function on a PIC16 microcontroller to log changes of state and save the results in an external EEPROM but it only has a resolution of 1 second.

Les.
 

Thread Starter

@vajra

Joined May 2, 2018
154
To what level of timing precision?

How to save / read / use the resulting data?

Think this through, you must understand that specifications are at least 30% of the job.
okay for example I have switch button, led and microcontroller so when I closed switch led become ON and when I open switch led become OFF
I can press the switch at any time, I want to store record, change of led state over time for 10 minutes.
 

LesJones

Joined Jan 8, 2017
4,190
The method I described should work if the 8051 has the interrupt on change function. Much of the code in the units that I have built is for the clock / calender function. You could simplify that part by using a real time clock chip such as the DS3231. For each event the time and date is stored plus a single byte that uses two bits for each channel (My unts use three channels,) One bit indicates that there has been a change of state on that channel and the other bit indicates if it was low to high or high to low.The data can be displayed on a 2 x 16 LCD display or sent out as serial data in text form that can be displayed on a PC.

Les.
 

shteii01

Joined Feb 19, 2010
4,644
Hardware interrupt makes most sense. INT0 or INT1. Once interrupt is triggered, the ISR is called, in the ISR you do the count.

You can also do ADC. 8051 ADC is 8 bits, so the digital range of values is between 0 and 255. ADC sample the signal, if below 127 that is low state, if above 127 that is high state, and just count how many times there is change from low to high or whatever you need.
 

Thread Starter

@vajra

Joined May 2, 2018
154
The method I described should work if the 8051 has the interrupt on change function. One bit indicates that there has been a change of state on that channel and the other bit indicates if it was low to high or high to low.The data can be displayed on a 2 x 16 LCD display or sent out as serial data in text form that can be displayed on a PC.

Les.
I think it would be good with python and raspberry pi. I can use a stamp library for the time

I need logic, I can implement logic into the program. Can you give me some pseudo code in c / python.
 

Sensacell

Joined Jun 19, 2012
3,453
okay for example I have switch button, led and microcontroller so when I closed switch led become ON and when I open switch led become OFF
I can press the switch at any time, I want to store record, change of led state over time for 10 minutes.
Still meaningless.

You need to define what the possible input range could be, using numbers.
How many times could it change state in the 10 minutes?
What would the shortest possible input pulse look like?

The solution depends on the details- always.
 

LesJones

Joined Jan 8, 2017
4,190
I am VERY VERY poor at "C" programming so have no idea how I would go about writing the program in "C". I have never even considered Python as it is not compiled. I can give you the source code in PIC assembler. My units are based on a PIC16F877 The assembler listing file is probably the easiest to read as the main assembler file uses some include files to do things like driving the LCD display and reading and writing the EEPROM. Let me know if you want this information and I will try to put it on dropbox so you can download it.

Les.
 
Top