When I was working building Stan’s TPS and Digital Means boards I wondered if I could duplicate their function using an Arduino UNO. I did try to do that but was not very happy with the results as the frequency was not very stable. I had looked at the Arduino PWM function as it does generate a wave train where you can vary the duty cycle, used to power motors for example. However, this only works at specify set frequencies. I also checked to see if there were any other circuits that were now available to vary duty cycle and could not find anything other than function generators.
I recently purchased an Arduino and experiment kit for my grandson so I thought I should brush up my Arduino knowledge and decided to take another look at using an Arduino UNO to simulate the TPS and Digital means boards.
My plans were to use a potentiometer as the TPS input to vary the duty cycle and use a frequency input as reference way train. Turned out I had problems accepting a low frequency input to use as a reference and wound up generating the frequency on the UNO using a second potentiometer. Once the desired frequency is set this pot can either be turned off with a switch so it does not change, or you can hard set frequency in code. There are comments in code and more detail in attached document.
I then searched the internet to see if I could find out if anyone had done something similar without much success. I did find that functions that allow the PWM to change duty cycle do not work below 100Hz and it even hard for normal frequency functions to work at low frequencies. After reading several articles and help requests, I finally found references to using the Arduino registers to generate low frequencies. Several provided code samples that said how to do this but did not explain why or that the names they were using were low-level standard names that complier knows how to use. They also used binary and hex values to set the register content.
I finally found 2 good articles that were a great help. The first explained the register structure and all the built-in names for each bit. It also showed how to set the bits to set the mode of operation (first built-in register). The second article used this register name to set mode but in detail explained how to set second register name which sets frequency that is used by PWM function and shows how to set the duty cycle.
Once I understood how to use the registers it was easy to build, and test see pictures and code below.
NOTE: The attached document has all the pictures, code, and more detail on references that explain how to use registers. It also has an example of how I set frequency in code with notes on problems I had and things to look out for.
The first picture is my test setup. Display is showing output and its inverse as Digital Means outputs both.
I recently purchased an Arduino and experiment kit for my grandson so I thought I should brush up my Arduino knowledge and decided to take another look at using an Arduino UNO to simulate the TPS and Digital means boards.
My plans were to use a potentiometer as the TPS input to vary the duty cycle and use a frequency input as reference way train. Turned out I had problems accepting a low frequency input to use as a reference and wound up generating the frequency on the UNO using a second potentiometer. Once the desired frequency is set this pot can either be turned off with a switch so it does not change, or you can hard set frequency in code. There are comments in code and more detail in attached document.
I then searched the internet to see if I could find out if anyone had done something similar without much success. I did find that functions that allow the PWM to change duty cycle do not work below 100Hz and it even hard for normal frequency functions to work at low frequencies. After reading several articles and help requests, I finally found references to using the Arduino registers to generate low frequencies. Several provided code samples that said how to do this but did not explain why or that the names they were using were low-level standard names that complier knows how to use. They also used binary and hex values to set the register content.
I finally found 2 good articles that were a great help. The first explained the register structure and all the built-in names for each bit. It also showed how to set the bits to set the mode of operation (first built-in register). The second article used this register name to set mode but in detail explained how to set second register name which sets frequency that is used by PWM function and shows how to set the duty cycle.
Once I understood how to use the registers it was easy to build, and test see pictures and code below.
NOTE: The attached document has all the pictures, code, and more detail on references that explain how to use registers. It also has an example of how I set frequency in code with notes on problems I had and things to look out for.
The first picture is my test setup. Display is showing output and its inverse as Digital Means outputs both.