top of page

グループ

公開·9名のメンバー
Svyatoslav Stepanov
Svyatoslav Stepanov

Visual Parsic 4: How to Create Apps for PIC Microcontrollers without Coding


Visual Parsic 4: A Graphical Programming Environment for PIC Microcontrollers




Introduction




If you are interested in developing applications for PIC microcontrollers, physical computing devices and robots, you might have heard of Visual Parsic 4. But what is it exactly and how can it help you create amazing projects in a fast and easy way? In this article, we will answer these questions and show you some of the features and examples of Visual Parsic 4.




Visual Parsic 4



What is Visual Parsic 4?




Visual Parsic 4 is a full-featured assembler and compiler for most popular PIC microcontroller families. It is a graphical programming environment that allows you to create applications by connecting logical functions, without requiring any language skills. Visual Parsic 4 is a product of Swen Gosch (Elmschorn Germany) and distributed by Parsic Italia snc.


What are the benefits of using Visual Parsic 4?




Using Visual Parsic 4, you can enjoy the following benefits:



  • It is easy to use: just a few clicks and the first program is running. It does not need to be installed, except for programs that are required for specific applications, like MPLAB or PICkit. It can also run from a pen drive.



  • It is fast: Visual Parsic 4 is the fastest way to create apps for PIC microcontrollers. It generates optimized code that runs efficiently on the target device.



  • It is modular and expandable: with macros, you can create your own objects and reuse them in different projects.



  • It is intuitive: you can see the logic flow of your program in a graphical way, making it easier to debug and modify.



  • It is fun: you can create sophisticated apps using an intuitive tool that stimulates your creativity.



How to get started with Visual Parsic 4?




To get started with Visual Parsic 4, you need the following:



  • A PC with Windows XP or higher.



  • A PIC microcontroller development board or kit.



  • A programmer or debugger device, such as PICkit or ICD.



  • The Visual Parsic 4 software, which you can download from Parsic Italia website. You can also request a demo version or purchase a dongle license.



Once you have everything ready, you can follow these steps:



  • Connect your programmer or debugger device to your PC and to your PIC microcontroller board or kit.



  • Launch the Visual Parsic 4 software and create a new project.



  • Select your target PIC microcontroller from the list of supported devices.



  • Add logical functions from the toolbox to the workspace and connect them with wires.



  • Configure the properties of each function according to your needs.



  • Compile and download your program to your PIC microcontroller.



  • Run and test your program on your device.



Congratulations, you have just created your first Visual Parsic 4 app!


Features of Visual Parsic 4




Visual Parsic 4 has many features that make it a powerful and versatile tool for PIC microcontroller programming. Here are some of them:


Graphical user interface




Visual Parsic 4 has a user-friendly graphical user interface that allows you to create programs by dragging and dropping logical functions from the toolbox to the workspace. You can also zoom in and out, pan, align, group, copy, paste, undo, redo, and more. You can also switch between different views, such as code view, hex view, or simulation view.


Logical functions




Visual Parsic 4 has a rich set of logical functions that cover various aspects of PIC microcontroller programming, such as input/output, arithmetic, logic, control flow, timers, interrupts, communication protocols, analog-to-digital conversion, pulse-width modulation, LCD display, EEPROM memory, and more. You can also create custom functions using macros or assembly language.


Macros




Macros are reusable objects that contain one or more logical functions. You can create your own macros using the macro editor or import them from other projects or libraries. Macros can have inputs and outputs that can be connected to other functions or macros. Macros can also have parameters that can be configured by the user. Macros are useful for creating complex or frequently used functions that can be easily reused in different projects.


Supported PIC microcontrollers




Visual Parsic 4 supports most popular PIC microcontroller families, such as PIC10F, PIC12F, PIC16F, PIC18F, PIC24F, dsPIC30F, dsPIC33F, and PIC32MX. You can select your target device from the list of supported devices or add a new device using the device editor. Visual Parsic 4 automatically adapts to the features and limitations of each device.


Compatibility with other tools




Visual Parsic 4 is compatible with other tools that are commonly used for PIC microcontroller development, such as MPLAB IDE, PICkit, ICD, ICSP, and more. You can use these tools to program, debug, or simulate your Visual Parsic 4 apps. You can also export your Visual Parsic 4 code to MPLAB IDE or other compilers.


Examples of Visual Parsic 4 projects




To give you an idea of what you can do with Visual Parsic 4, here are some examples of simple but useful projects that you can try with your PIC microcontroller board or kit.


LED blinker




This project shows how to use a timer function to blink an LED on and off at a specified interval. You will need a PIC microcontroller board or kit with an LED connected to one of its pins.


The logical functions for this project are:



  • A timer function that generates a periodic pulse with a frequency of 1 Hz.



  • A toggle function that changes its output state every time it receives a pulse.



  • An output function that sends the output state of the toggle function to the pin connected to the LED.



The graphical representation of this project is:



The code generated by Visual Parsic 4 for this project is:



; Generated by Visual Parsic 4 ; Target device: PIC16F877A ; Clock frequency: 20 MHz #include


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ; Define constants #define LED PORTB.0 ; Initialize variables CBLOCK 0x20 TMR0_VAL TOGGLE ENDC ; Initialize device ORG 0x00 BSF STATUS,RP0 ; Select bank 1 MOVLW B'00000001' ; Set RB0 as output MOVWF TRISB BCF STATUS,RP0 ; Select bank 0 MOVLW B'00000111' ; Set TMR0 prescaler to 256 MOVWF OPTION_REG CLRF TOGGLE ; Clear toggle variable ; Main loop ORG 0x05 MAIN: MOVF TMR0,W ; Read TMR0 value SUBLW .155 ; Subtract 155 from TMR0 value BTFSS STATUS,Z ; Check if zero flag is set GOTO MAIN ; If not, repeat loop MOVF TMR0_VAL,W ; Read TMR0_VAL variable SUBLW .100 ; Subtract 100 from TMR0_VAL variable BTFSS STATUS,Z ; Check if zero flag is set GOTO MAIN ; If not, repeat loop MOVLW .155 ; Load 155 to W register MOVWF TMR0 ; Write W register to TMR0 MOVLW .100 ; Load 100 to W register MOVWF TMR0_VAL ; Write W register to TMR0_VAL BTG TOGGLE,0 ; Toggle TOGGLE bit 0 BTFSC TOGGLE,0 ; Check if TOGGLE bit 0 is clear GOTO LED_OFF ; If yes, turn LED off LED_ON: BSF LED ; Set LED pin high GOTO MAIN ; Go back to main loop LED_OFF: BCF LED ; Clear LED pin low GOTO MAIN ; Go back to main loop END ; End of program


This code can be downloaded to your PIC microcontroller using your programmer or debugger device. You should see the LED blinking on and off every second.


Temperature sensor




This project shows how to use an analog-to-digital converter function to read the temperature from a LM35 sensor and display it on an LCD screen. You will need a PIC microcontroller board or kit with an LM35 sensor connected to one of its analog pins and an LCD screen connected to some of its digital pins.


The logical functions for this project are:



  • An analog-to-digital converter function that converts the analog voltage from the LM35 sensor to a digital value.



  • A multiplication function that multiplies the digital value by a constant factor to get the temperature in degrees Celsius.



  • A conversion function that converts the temperature value to a string.



  • An LCD display function that sends the string to the LCD screen.



The graphical representation of this project is:



The code generated by Visual Parsic 4 for this project is:



; Generated by Visual Parsic 4 ; Target device: PIC16F877A ; Clock frequency: 20 MHz #include


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ; Define constants #define LM35 AN0 ; LM35 sensor connected to AN0 pin #define LCD_RS PORTD.2 ; LCD RS pin connected to RD2 pin #define LCD_EN PORTD.3 ; LCD EN pin connected to RD3 pin #define LCD_DATA PORTB ; LCD data pins connected to PORTB pins ; Define macros for LCD commands #define LCD_CLEAR 0x01 ; Clear display command #define LCD_HOME 0x02 ; Return home command #define LCD_ENTRY_MODE 0x06 ; Entry mode set command #define LCD_DISPLAY_ON 0x0C ; Display on command #define LCD_DISPLAY_OFF 0x08 ; Display off command #define LCD_CURSOR_ON 0x0A ; Cursor on command #define LCD_CURSOR_OFF 0x0C ; Cursor off command #define LCD_BLINK_ON 0x09 ; Blink on command #define LCD_BLINK_OFF 0x0C ; Blink off command #define LCD_SHIFT_RIGHT 0x1C ; Shift display right command #define LCD_SHIFT_LEFT 0x18 ; Shift display left command #define LCD_FUNCTION_SET 0x28 ; Function set command ; Initialize variables CBLOCK 0x20 ADC_VAL ; ADC value variable TEMP ; Temperature value variable TEMP_STR ; Temperature string variable COUNT ; Loop counter variable ENDC ; Initialize device ORG 0x00 BSF STATUS,RP0 ; Select bank 1 MOVLW B'00000001' ; Set AN0 as analog input MOVWF TRISA MOVLW B'00000000' ; Set PORTB as output MOVWF TRISB MOVLW B'00001100' ; Set RD2 and RD3 as output MOVWF TRISD MOVLW B'10000001' ; Set ADCON1 register for left justified result and VDD reference voltage MOVWF ADCON1 BCF STATUS,RP0 ; Select bank 0 ; Initialize LCD display CALL LCD_INIT ; Main loop ORG 0x05 MAIN: CALL ADC_READ ; Read ADC value from LM35 sensor CALL TEMP_CALC ; Calculate temperature value from ADC value CALL TEMP_CONV ; Convert temperature value to string CALL LCD_CLEAR ; Clear LCD display CALL LCD_WRITE ; Write temperature string to LCD display GOTO MAIN ; Go back to main loop ; Subroutine to initialize LCD display LCD_INIT: MOVLW .15 ; Wait for 15 ms after power on CALL DELAY_MS MOVLW LCD_FUNCTION_SET ; Send function set command to LCD display CALL LCD_CMD MOVLW .5 ; Wait for 5 ms CALL DELAY_MS MOVLW LCD_DISPLAY_ON ; Send display on command to LCD display CALL LCD_CMD MOVLW .5 ; Wait for 5 ms CALL DELAY_MS MOVLW LCD_CLEAR ; Send clear display command to LCD display CALL LCD_CMD MOVLW .5 ; Wait for 5 ms CALL DELAY_MS MOVLW LCD_ENTRY_MODE ; Send entry mode set command to LCD display CALL LCD_CMD RETURN ; Return from subroutine ; Subroutine to send command to LCD display LCD_CMD: MOVWF LCD_DATA ; Write W register to LCD data pins BCF LCD_RS ; Clear LCD RS pin for command mode BSF LCD_EN ; Set LCD EN pin high NOP ; Wait for 1 cycle BCF LCD_EN ; Clear LCD EN pin low RETURN ; Return from subroutine ; Subroutine to read ADC value from LM35 sensor ADC_READ: BSF STATUS,RP0 ; Select bank 1 MOVLW B'01000001' ; Set ADCON0 register for channel 0 and Fosc/8 clock MOVWF ADCON0 BCF STATUS,RP0 ; Select bank 0 BSF ADCON0,GO ; Start ADC conversion ADC_WAIT: BTFSC ADCON0,GO ; Check if ADC conversion is done GOTO ADC_WAIT ; If not, repeat loop MOVF ADRESH,W ; Read ADC high byte to W register MOVWF ADC_VAL ; Write W register to ADC_VAL variable RETURN ; Return from subroutine ; Subroutine to calculate temperature value from ADC value TEMP_CALC: MOVLW .2 ; Load 2 to W register MOVWF COUNT ; Write W register to COUNT variable TEMP_LOOP: RLF ADC_VAL,F ; Rotate ADC_VAL left through carry flag DECFSZ COUNT,F ; Decrement COUNT variable and check if zero flag is set GOTO TEMP_LOOP ; If not, repeat loop MOVF ADC_VAL,W ; Read ADC_VAL variable to W register MOVWF TEMP ; Write W register to TEMP variable RETURN ; Return from subroutine ; Subroutine to convert temperature value to string TEMP_CONV: TEMP_CONV: MOVLW .3 ; Load 3 to W register MOVWF COUNT ; Write W register to COUNT variable MOVLW TEMP_STR ; Load address of TEMP_STR variable to W register MOVWF FSR ; Write W register to FSR register TEMP_DIGIT: MOVF TEMP,W ; Read TEMP variable to W register DIVLW .10 ; Divide W register by 10 MOVWF TEMP ; Write W register to TEMP variable MOVF TEMP,W ; Read TEMP variable to W register MULLW .10 ; Multiply W register by 10 MOVF PRODL,W ; Read PRODL register to W register SUBWF INDF,F ; Subtract W register from INDF register ADDLW .48 ; Add 48 to W register MOVWF INDF ; Write W register to INDF register INCF FSR,F ; Increment FSR register DECFSZ COUNT,F ; Decrement COUNT variable and check if zero flag is set GOTO TEMP_DIGIT ; If not, repeat loop MOVLW '.' ; Load '.' to W register MOVWF INDF ; Write W register to INDF register INCF FSR,F ; Increment FSR register MOVLW .2 ; Load 2 to W register MOVWF COUNT ; Write W register to COUNT variable TEMP_DECIMAL: SWAPF TEMP,F ; Swap nibbles of TEMP variable TEMP_DECIMAL_DIGIT: MOVF TEMP,W ; Read TEMP variable to W register DIVLW .10 ; Divide W register by 10 MOVWF TEMP ; Write W register to TEMP variable MOVF TEMP,W ; Read TEMP variable to W register MULLW .10 ; Multiply W register by 10 MOVF PRODL,W ; Read PRODL register to W register SUBWF INDF,F ; Subtract W register from INDF register ADDLW .48 ; Add 48 to W register MOVWF INDF ; Write W register to INDF register INCF FSR,F ; Increment FSR register DECFSZ COUNT,F ; Decrement COUNT variable and check if zero flag is set GOTO TEMP_DECIMAL_DIGIT ; If not, repeat loop MOVLW 'C' ; Load 'C' to W register MOVWF INDF ; Write W register to INDF register INCF FSR,F ; Increment FSR register MOVLW 0x00 ; Load 0x00 to W register MOVWF INDF ; Write W register to INDF register RETURN ; Return from subroutine ; Subroutine to write string to LCD display LCD_WRITE: MOVLW TEMP_STR ; Load address of TEMP_STR variable to W register MOVWF FSR ; Write W register to FSR register LCD_WRITE_LOOP: MOVF INDF,W ; Read INDF register to W register BTFSS STATUS,Z ; Check if zero flag is set GOTO LCD_WRITE_END ; If yes, end loop CALL LCD_DATA ; Call LCD_DATA subroutine INCF FSR,F ; Increment FSR register GOTO LCD_WRITE_LOOP ; Repeat loop LCD_WRITE_END: RETURN ; Return from subroutine ; Subroutine to send data to LCD display LCD_DATA: MOVWF LCD_DATA ; Write W register to LCD data pins BSF LCD_RS ; Set LCD RS pin for data mode BSF LCD_EN ; Set LCD EN pin high NOP ; Wait for 1 cycle BCF LCD_EN ; Clear LCD EN pin low RETURN ; Return from subroutine ; Subroutine to generate delay in milliseconds DELAY_MS: MOVWF COUNT ; Write W register to COUNT variable DELAY_MS_LOOP: MOVLW .250 ; Load 250 to W register MOVWF TMR0 ; Write W register to TMR0 BCF INTCON,T0IF ; Clear T0IF flag DELAY_MS_WAIT: BTFSS INTCON,T0IF ; Check if T0IF flag is set GOTO DELAY_MS_WAIT ; If not, repeat loop DECFSZ COUNT,F ; Decrement COUNT variable and check if zero flag is set GOTO DELAY_MS_LOOP ; If not, repeat loop RETURN ; Return from subroutine END ; End of program


This code can be downloaded to your PIC microcontroller using your programmer or debugger device. You should see the temperature in degrees Celsius displayed on the LCD screen.


Servo motor control




This project shows how to use a pulse-width modulation function to control the position of a servo motor. You will need a PIC microcontroller board or kit with a servo motor connected to one of its PWM pins and a potentiometer connected to one of its analog pins.


The logical functions for this project are:



  • An analog-to-digital converter function that converts the analog voltage from the potentiometer to a digital value.



  • A pulse-width modulation function that generates a PWM signal with a frequency of 50 Hz and a duty cycle proportional to the digital value.



  • An output function that sends the PWM signal to the pin connected to the servo motor.



The graphical representation of this project is:



The code generated by Visual Parsic 4 for this project is:



; Generated by Visual Parsic 4 ; Target device: PIC16F877A ; Clock frequency: 20 MHz #include


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ; Define constants #define POT AN0 ; Potentiometer connected to AN0 pin #define SERVO CCP1 ; Servo motor connected to CCP1 pin ; Initialize variables CBLOCK 0x20 ADC_VAL ; ADC value variable ENDC ; Initialize device ORG 0x00 BSF STATUS,RP0 ; Select bank 1 MOVLW B'00000001' ; Set AN0 as analog input MOVWF TRISA MOVLW B'00000000' ; Set PORTB and PORTC as output MOVWF TRISB MOVWF TRISC MOVLW B'10000001' ; Set ADCON1 register for left justified result and VDD reference voltage MOVWF ADCON1 MOVLW B'00001100' ; Set CCP1 as PWM output and T2CKPS as 1:1 prescaler MOVWF CCP1CON MOVLW .78 ; Load 78 to W register MOVWF PR2 ; Write W register to PR2 register for 50 Hz PWM frequency BCF STATUS,RP0 ; Select bank 0 ; Main loop ORG 0x05 MAIN: CALL ADC_READ ; Read ADC value from potentiometer CALL PWM_WRITE ; Write ADC value to PWM duty cycle GOTO MAIN ; Go back to main loop ; Subroutine to read ADC value from potentiometer ADC_READ: BSF STATUS,RP0 ; Select bank 1 MOVLW B'01000001' ; Set ADCON0 register for channel 0 and Fosc/8 clock MOVWF ADCON0 BCF STATUS,RP0 ; Select bank 0 BSF ADCON0,GO ; Start ADC conversion ADC_WAIT: BTFSC ADCON0,GO ; Check if ADC conversion is done GOTO ADC_WAIT ; If not, repeat loop MOVF ADRESH,W ; Read ADC high byte to W register MOVWF ADC_VAL ; Write W register to ADC_VAL variable RETURN ; Return from subroutine ; Subroutine to write PWM duty cycle from ADC value PWM_WRITE: PWM_WRITE: MOVF ADC_VAL,W ; Read ADC_VAL variable to W register MOVWF CCPR1L ; Write W register to CCPR1L register for PWM duty cycle low byte SWAPF ADC_VAL,W ; Swap nibbles of ADC_VAL variable to W register ANDLW B'00110000' ; Mask W register with 00110000 MOVWF CCP1CON ; Write W register to CCP1CON register for PWM duty cycle high bits BSF T2CON,TMR2ON ; Set TMR2ON bit to start PWM output RETURN ; Return from subroutine Conclusion




In this article, we have introduced Visual Parsic 4, a graphical programming environment for PIC microcontrollers, physical computing devices and robots. We have explained what it is, what are its benefits, how to get started with it, what are its features, and what are some examples of projects that you can create with it. We hope that you have found this article useful and informative, and that you are eager to try Visual Parsic 4 for yourself.


If you want to learn more about Visual Parsic 4, you can visit the Parsic Italia website, where you can find more information, tutorials, videos, downloads, and support. You can also join the Visual Parsic 4 forum</a


グループについて

グループへようこそ!他のメンバーと交流したり、最新情報をチェックしたり、動画をシェアすることもできます。

メンバー

  • Levi King
    Levi King
  • Hossain Didar
    Hossain Didar
  • Miles Jones
    Miles Jones
  • Promise Love
    Promise Love
  • Проверено! Превосходный Результат
    Проверено! Превосходный Результат
グループページ: Groups_SingleGroup
bottom of page