<< Chapter < Page Chapter >> Page >
Flexible Pulse Width Controller

Redesign the PicoBlaze design so that pulse width high and lows can be controlled independently. Perform this task using INPUT instruction and allocating two input registers- one for high pulse and another for low pulse widths. Modify the assembler code accordingly, assemble it, and assign to the ROM table. Run the simulation and observe the pulse output.

  • Modify the assembler code to get high pulse and low pulse widths selection independently
    One method is to define constants in the code and have the loop re-written so that one part of it generates high pulse and another part of the loop to generate low output. Another method is to implement some kind of multiplexer with a register to define the high output pulse and a register to define the low output pulse width.
    Change the code so that you use the INPUT instruction to access the two registers. For example, INPUT input_high_pw, input_high_port which reads the high value from the input_high_port address

    Think about what address the registers will be at and how you will decode the address. How will the address be qualified?

    ;simple example of PWM using picoblaze ; ;Naming ports and assigning values ; CONSTANT pw_port, 02 ; CONSTANT input_high_port, 01 ;pulsewidth high value port CONSTANT input_low_port, 00 ;pulsewidth low value port ; ;Naming registers ; NAMEREG s01, pw_data ;used to form base of software delay loops NAMEREG s02, input_high_pw ;register to store pulse width high value NAMEREG s03, input_low_pw ;register to store pulse width low value NAMEREG s04, pw_high_delay_reg ;used to form base of software delay loops NAMEREG s05, pw_low_delay_reg ;used to form base of software delay loops ; ;Start of program and initialisation of displays ; start LOAD pw_high_delay_reg, 00 ;lets clear the registers LOAD pw_low_delay_reg, 00 ;lets clear the registers OUTPUT pw_data, pw_port ;lets set the data to be 0 for now ;read the high and low values INPUT input_high_pw, input_high_port ;read the high value LOAD pw_data,00 ;load the register with the data to be output INPUT input_low_pw, input_low_port ;read the low value ;start the loops load_values LOAD pw_high_delay_reg, input_high_pw ;load pulse width register LOAD pw_low_delay_reg, input_low_pw ;do the high pulse width pw_high_loop SUB pw_high_delay_reg, 01 ;little JUMP NZ, pw_high_loop ; XOR pw_data, 01 ;invert the data OUTPUT pw_data, pw_port ; ;do the low pulse width pw_low_loop SUB pw_low_delay_reg, 01 ; little JUMP NZ, pw_low_loop ; XOR pw_data, 01 ;invert the data OUTPUT pw_data, pw_port JUMP load_values; start again

  • Add two constants, necessary registers, and additional control strobes
  • Assemble the source code using the perl command
  • Assign the code to the ROM table
  • Modify the design as necessary
  • Run the simulation and observe that the output pulse width has changed
  • Save the model and close MATLAB

Conclusion

In this lab you learned how to develop a PicoBlaze design by using simple pulse width application. You also learned how to add external registers to the design and pass the information to the program.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Xilinx university program: professor workshop. OpenStax CNX. Jun 24, 2004 Download for free at http://cnx.org/content/col10233/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Xilinx university program: professor workshop' conversation and receive update notifications?

Ask