Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

This topic contains 9 replies, has 2 voices, and was last updated by  Bitahwa Bindu 1 year, 1 month ago.

  • Author
    Posts
  • #2805

    ncyierra
    Participant

    The EMG click code is for PIC18F87K22(EasyV7 Pro). How can I change the code and use it on PIC18F4862(EasyV7)????

  • #2806

    Bitahwa Bindu
    Keymaster

    Hi. That shouldn’t be a problem. Just change your PIC in Project edit menu. Most of other stuff if any should be easy to change.

    You must zip your full project files first before uploading them.

  • #2807

    ncyierra
    Participant

    I am going to be using Mikroplot as well. Do you know if that will be a problem? Is mikroplot for a specific PIC or can it work for all of them? if so how do I change the project settings for it to work with the PIC that I have?

    Thanks

  • #2808

    Bitahwa Bindu
    Keymaster

    I am sure any PIC with a serial port could work with mikroplot. Did you read this ECG Tutorial ?

     

  • #2809

    ncyierra
    Participant

    I read the tutorial. I think the problem is with the code.

    I still don’t know how to change the PIC18F87K22 code to work for PIC184862.

    #include <stdint.h>
    #include <stdbool.h>

    void InitTimer1(){
    // 200 Hz / 5 ms
    T1CON = 0x11;
    TMR1IF_bit = 0;
    TMR1H = 0x63;
    TMR1L = 0xC0;
    TMR1IE_bit = 1;
    INTCON = 0xC0;
    }

    static bool read_flag = false;
    static volatile uint32_t interrupt_ctr = 0;
    static volatile uint32_t seconds_counter = 0;
    uint32_t adc_reads;
    double timer_reads;

    void main()
    {
    uint32_t i = 0;
    char timer_read_string[10];
    char final_string [20];

    TRISA0_bit = 1; // Set A15 and B8 pins as input
    TRISB7_bit = 1;

    ADC_Init();

    UART1_Init(57600);
    delay_ms(500);

    while(1)
    {
    // If the button on PORTB7 is pressed, interrupts are activated
    // and the measuring begins
    if (Button(&PORTB, 7, 10, 1))
    {
    UART1_Write_Text(“START\r\n”);
    delay_ms(500);
    InitTimer1();
    }

    // Every 3.3 ms measure data and send them to mikroPlot
    if (read_flag == true)
    {
    TMR1IE_bit = 0;
    adc_reads = ADC_Get_Sample(0);
    timer_reads = ((double)interrupt_ctr) * 5.00;
    inttostr(adc_reads, final_string);
    floattostr(timer_reads, timer_read_string);
    strcat(final_string, “,”);
    strcat(final_string, timer_read_string);
    ltrim(final_string);
    UART1_Write_Text(final_string);
    UART1_Write_Text(“\r\n”);
    read_flag = false;
    TMR1IE_bit = 1;
    }
    }

    }
    void Interrupt(){
    if (TMR1IF_bit){
    TMR1IF_bit = 0;
    TMR1H = 0x63;
    TMR1L = 0xC0;

    read_flag = true;

    interrupt_ctr++;
    if (interrupt_ctr % 200 == 0)
    seconds_counter++;
    }
    }

  • #2810

    Bitahwa Bindu
    Keymaster

    In project settings you can change the PIC as shown in this video from 11:05 min: Introduction to mikroC Pro for PIC

     

  • #2811

    ncyierra
    Participant

    Hi,

    I changed the project settings like you say in your video. I was able to compile the code without errors. The code was written for PIC18F87K22 so I imagine some command lines would have to be changed for the code to work for a different MCU(PIC18F4682). This is the problem I am having. The USART worked but displays wrong information. I am not too familiar with MikroC that is why I don’t know how to make it work. Mikroplot connects but doesn’t display any electrical activity; I am guessing because the code doesnt display the right results.

    Attachments:
    You must be logged in to view attached files.
  • #2813

    Bitahwa Bindu
    Keymaster

    How did you set your clock oscillator frequency?

    Is your frequency in software the same as in your hardware? Can you upload your code ?

     

  • #2814

    ncyierra
    Participant

    Hi,

    Thank you. I was able to get MikroElektronika to fix the code.

    Attachments:
    You must be logged in to view attached files.
  • #2816

    Bitahwa Bindu
    Keymaster

    That’s great to hear. What was the problem in the code?

You must be logged in to reply to this topic.

Select your currency
EUR Euro
USD United States (US) dollar