10440 views|7 replies

26

Posts

0

Resources
The OP
 

Single chip microcomputer frequency multiplication problem [Copy link]

I want to convert a 50Hz pulse signal into a 500Hz output after passing through a 51 single-chip microcomputer. I wrote a program but it can't be realized. I hope the experts can give me some advice. Thank you! The detection time for the input signal is 0.5S, and the output is 500Hz after the detection. There is no problem with the output part, but I don't understand how to deal with the detection of input signal #include "reg52.h" sbit PWM_out=P1^0; //define output pin sbit PWM_in=P1^5; //define input pin unsigned int count=0; //count the number of pulses void main() { TMOD=0x01; //Timer 0 working mode 1 TH0=(65536-1000)/256; //12M crystal oscillator 1ms timing constant TL0=(65536-1000)%256; EA=1; //Open total interrupt ET0=1; //Open timer 0 interrupt TR0=0; //Do not start timer 0 while(1); if ((P1^5==1)&&(P1^5==0)) { count++; if((count >= 45)&&(count <= 55)) { TR0=1; } else { TR0=0; } } } void T0_time(void) interrupt 1 //interrupt function, enter an interrupt every 1ms after startup{ TH0=(65536-1000)/256; //12M crystal oscillator 1ms timing constant TL0=(65536-1000)%256; if(PWM_out) PWM_out=0; //invert the output pin else PWM_out=1; }

This post is from 51mcu

Latest reply

You can measure the frequency first. If it is just this indicator, 51 can handle it.  Details Published on 2018-5-13 15:50
 

152

Posts

0

Resources
2
 
This needs to be done with timer input capture. Your approach is a bit wrong, and the count is not cleared to 0.
This post is from 51mcu
 
 
 

6

Posts

0

Resources
3
 
   if ((P1^5==1)&&(P1^5==0)) When will this be true and the count keeps increasing?
This post is from 51mcu
 
 
 

2921

Posts

0

Resources
4
 
The original poster's problem is that the input signal fluctuates around 50 Hz, but the output frequency is always 100 times the input. If the input does not change, there is no need for this circuit, and a 500 Hz signal can be directly used. Therefore, the problem is actually to make a software phase-locked loop to achieve 100 times the frequency. The solution given by the original poster in the first post seems to be too simple.
This post is from 51mcu

Comments

Hello, great master, we meet again. I wanted to solve the frequency multiplication problem with pure hardware before, but later found it difficult. Although I had the information provided by the great master, I still couldn't do it. The leader urged me to change the plan, so I used a single-chip microcomputer to solve the frequency multiplication problem. The overall idea is this: ARM wants to drive the stepper motor, but  Details Published on 2018-5-13 06:04
 
 
 

26

Posts

0

Resources
5
 
gmchen posted on 2018-5-12 21:12 The original poster's problem is that the input signal fluctuates around 50 Hz and the output frequency is always required to be 100 times the input, because if the input does not change, then it will not...
Hello, great god, we meet again. I wanted to use pure hardware to solve the frequency multiplication problem before, but later found that it was difficult. Although I had the information provided by the great god to assist, I still couldn't do it. The leader urged me to change the plan, so I used a single-chip microcomputer to solve the frequency multiplication problem. The overall idea is this: ARM wants to drive the stepper motor, but if the frequency of the pulse signal to the stepper motor is greater than 1K, the ARM system will freeze. If the frequency is less than 1K, there will be no problem. A total of 8 frequencies are required to allow the stepper motor to have different speeds under different circumstances. The driving frequency is 0.5K, 1K, 1.6K, 2.1K, 2.6K, 3.1K, 3.6K, 4.1K. So I want the ARM to output a low frequency, and then convert it into a high frequency that is amplified 10 times through the microcontroller frequency multiplication circuit. Now I ask for help from the master to give a program to process the input pulse signal, and then I will figure it out myself later.
This post is from 51mcu

Comments

Since there are only these 8 frequencies, and they are known fixed frequencies, why do we need frequency multiplication? Isn't it enough for ARM to give an instruction directly, and then the microcontroller will output the specified frequency?  Details Published on 2018-5-13 08:17
 
 
 

2921

Posts

0

Resources
6
 
HT001 posted on 2018-5-13 06:04 Hello, great master, we meet again. I wanted to solve the frequency multiplication problem with pure hardware before, but later found it difficult. Although I have the information provided by the great master, I still...
Since there are only these 8 frequencies, and they are known fixed frequencies, why do we need frequency multiplication? Can't we just give an instruction directly from ARM, and then the microcontroller outputs the specified frequency?
This post is from 51mcu

Comments

I didn't expect this. I'll confirm this with the programmer on Monday. Thank you!  Details Published on 2018-5-13 08:34
 
 
 

26

Posts

0

Resources
7
 
gmchen posted on 2018-5-13 08:17 Since there are only these 8 frequencies, and they are known fixed frequencies, why do we need frequency multiplication? ARM directly gives an instruction, and then the microcontroller outputs the specified frequency...
I really didn't expect this. I will confirm it with the programmer on Monday. Thank you!
This post is from 51mcu
 
 
 

4005

Posts

0

Resources
8
 
You can measure the frequency first. If it is just this indicator, 51 can handle it.
This post is from 51mcu
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list