[SOLVED !] Help for Fatigue testing controller


Today 06:21
Forum: LCD module
Starter: charliecoultas
Views: 0
Replies: 31
Yesterday 23:16
Forum: The Lounge
Starter: keytapper
Views: 0
Replies: 8
Yesterday 22:07
Forum: Proton Users File Server
Starter: top204
Views: 0
Replies: 0
Yesterday 20:45
Forum: CAN Module
Starter: RGV250
Views: 0
Replies: 0
Closed Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Help for Fatigue testing controller188 days old

  1. #1
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    1 Not allowed!

    Default Help for Fatigue testing controller

    Iam making LCD based fatigue test controller.In My program My UP & UD does not work when i set it to Word and lcd hangs.I have problem in Frequency and RPM Routine which is based on counter pulse.

    my Program

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2018 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 6/29/2018 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    Device = 16F877A
    Xtal = 16
    Include "MODEDEFS.BAS"
    All_Digital = True
    Declare LCD_DTPin = PORTB.4
    Declare LCD_RSPin = PORTB.2
    Declare LCD_ENPin = PORTB.3
    Declare LCD_Interface = 4
    Declare LCD_Lines = 4
    Declare LCD_Type = 0




    Symbol SOL = PORTB.1
    Symbol TARE = PORTD.3
    Symbol ADDO = PORTD.1
    Symbol ADSK = PORTD.0


    Dim onn As Word
    Dim offf As Word
    Dim telbit As Byte
    Dim teller As Float
    Dim n As Float
    Dim adjval As Word
    Dim countr As Float
    Dim countrr As Float
    Dim disval As Float
    Dim i As Byte
    Dim COUN As Dword
    Dim gram As Float


    TRISA=1
    TRISC=%11111111
    TRISB=%00111111
    TRISD=%11111110
    TRISE=0


    offf=0
    onn=0
    teller=0


    Main:






    ADDO=1 'hx711 logic
    ADSK=0
    COUN=0
    While ADDO=1:Wend
    For i= 0 To 23
    ADSK=1
    COUN=COUN<<1
    ADSK=0
    If ADDO =1 Then Inc COUN
    Next i
    ADSK=1
    COUN=COUN^0x800000
    gram=8388608-COUN
    gram=gram/100

    If TARE=0 Then 'tare routine
    adjval=gram
    EndIf
    disval=gram-adjval
    ADSK=0





    If PORTC.5=1 Then 'counter
    If telbit=0 Then
    Inc teller
    EndIf
    telbit=1
    Else
    telbit=0
    EndIf






    DelayMS offf 'relay logic for off
    High PORTB.1
    DelayMS onn 'relay logic for on
    Low PORTB.1

    If PORTD.4=1 Then offf=ERead 00
    If PORTD.4=1 Then Inc offf
    If PORTD.4=0 Then EWrite 00,[offf] 'off timer for relay

    If PORTD.5=1 Then offf=ERead 00
    If PORTD.5=1 Then offf=offf-1
    If PORTD.5=0 Then EWrite 00,[offf]



    If PORTD.6=1 Then onn=ERead 04
    If PORTD.6=1 Then Inc onn
    If PORTD.6=0 Then EWrite 04,[onn] 'onn timer for relay

    If PORTD.7=1 Then onn=ERead 04
    If PORTD.7=1 Then onn=onn-1
    If PORTD.7=0 Then EWrite 04,[onn]




    Print At 2,1,"FREQ=",Dec0 n," "
    Print At 1,1,"LOAD=",Dec1 disval," "
    Print At 3,1,"COUNTER=",Dec0 teller," "
    Print At 4,1,"UP=",Dec0 offf," "
    Print At 4,12,"UD=",Dec0 onn," "
    GoTo Main




    please help me.IMG_20190312_204409.jpg

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,311
    Thumbs Up
    Received: 79
    Given: 39
    Total Downloaded
    3.36 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    I have a feeling that DELAYMS with a value of zero specified will wait forever.
    I think you code might do this.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    How can I convert my counter to rpm and frequency and how to make peak hold in load values.in load iam using load cell.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    481
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.26 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    For UP and UD have you tried try replacing DEC0 with DEC, as those are word values and not floating point.
    By specifying the number of digits to display after the decimal point you may be tripping up the compiler up as I presume it would then be expecting to receive a floating point value to work with and you are not giving it one.

    I did not fully understand your code and I am sure there are many ways to convert a count to RPM/Frequency but I would think the simplest and best would be to use a timer interrupt...

    Setup your timer to interrupt at an appropriate time, i.e 1 minute, 100mS, 1mS, when the timer interrupts
    Code:
    'Timer Interrupt Psuedo code
    Get count
    Adjust count to give RPM, i.e. assuming 1 count = 1 revolution then 10 counts in 100ms = 6000 counts in 1 minute = 6000RPM
    Adjust count to give frequency, assuming same count value is being used and that both the duration of and interval between input pulses is constant then...
    1 count = 10mS (100mS/10) thus Frequency = 1/0.01 or (1/1e-3) = 100Hz
    
    Clear count
    reset timer
    Exit Interrupt
    You appear to be using a direct read of a port pin in your main code flow to get your counts (If PortC.5=1), if that is correct it may not be a very good or accurate way of doing it because if it is high for along time compared to the code execution you may be reading the same input pulse multiple times, equally if it is fast compared to execution time (Print routine uses a lot of instructions and so take a while to execute) you may miss some counts.

    Consequently, I think a better way of counting your input pulses may be to use a port pin with interrupt on change (IOC) or use your input pulse as the external clock source for one of the PIC's timers, it should be more accurate as you are less likely to count the same pulse twice or miss a pulse. Personally, I would go with the timer where possible as it can tick along on its own (until you reset it) without interrupting main code flow unlike the IOC which jumps off to an interrupt handler.

    Opps..
    forgot the peak hold. Simple create a variable, copy the first value into it, then compare it to subsequent values, if the subsequent value is higher then replace it, if not retain it. You can either keep it as an on going value or reset set it every 10, 100, 1000 reads as necessary.
    Last edited by Stephen Moss; 15th March 2019 at 10:03.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    Problem solved. thanks

    I want to add a potentiometer based on delay timer upto 1 minute.
    Pls guide .A sample program will be best for timer as well as RPM.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    481
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.26 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    I assuming you want to read a potentiometer and for that reading to set your time delay.
    If that is correct then...
    Read Potentiometer value, use ADin Commands (unless you prefer writing to the registers) and obviously an analogue input pin, i.e.
    Code:
    'ADC setup commands go before using the ADin command
    Dim Potentiometer as Byte (or Word if 10 bit ADC)
    Potentiometer = ADin 1  'Read value
    If using the delay commands then
    Divide the ADC value by 4 (8 bit ADC) or by 17(10 bit ADC), a 10bit ADC would be best as that get 0 - 60, where an 8 bit ADC get 0 - 64
    Muiltply that value by 1000 then use the Delay MS command, i.e.
    Code:
    'Delay Psuedo Code (Using Delay command)
    Seconds = Potentiometer/17   '10bit ADC
    DelayMs (Seconds *1000)
    This will give you a delay from 0 to 60 seconds in 1 second increments

    If using one of the PIC timers to create the delay can be done but is more involved as...
    you will need to modify the ADC reading by the correct amount.
    Initally
    Code:
    'Psuedo code for Timer Initialsiation 
    stop the timer counting (if possible)
    write the correct value to the timer
    Start the timer (if stopped)
    then
    Code:
    'Psuedo code for Timer Interrupt
    stop timer count (if possible)
    do your timer related event here (or set a flag for main code to act upon as interrupt code should be as short as possible)
    read the potentiomer value in case it has changed
    write the correct value to the timer
    Start the timer (if stopped)
    However it may not be a simple as that because if the clock speed and size of your timer means it rolls over too fast to use that method you will have to use the timer interrupt to increment a variable to keep track of how many interrupts have occurred and use that value to trigger your timer related event.
    For example if the slowest you can set your timer to roll over is 1mS your interrupt counter will update 1000 times a second, consequently you could use the "Seconds" value obtained from the "Delay Command" code above and say...
    Code:
    Seconds = Seconds * 1000  'Convert Seconds into the number of timer interrupts required - Seconds will need to be a Word size variable as would your timer interrupt count
      
    'Pseudo code for Timer interupt count delay   
    If Interrupt_Count = Seconds then
    Interrupt_Count = 0   'Reset the timer interrupt count - this should be done first to keep the the timing as accurate as possible
    Enter your timer event code here
    End If
    I am not going to provide exact code as I do not have the time and you will learn more doing it yourself but hopefully this will give you some ideas/point you in the right direction also try looking in the sample folder as there may already be examples of different delay methods there

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    Thanks Stephen Moss.

    Another problem in my set point counter.Iam making a counter maximum 60 pulse.And set point is maximum 60

    My problem is that when it reaches set point it doesn't stop it remains increasing.suppose my set point is 45 and my counter starts with zero and reaches 45 then it should fix on 45 .it should does not increase.

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    481
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.26 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    It is not clear how you are incrementing your set point counter as you have not provided any code or other information but if you are simply incrementing a variable value surely placing the increment code inside a simple conditional statement would suffice, i.e.
    Code:
    If count < 45 then
    count = count + 1   'Add one to the count only if the current count value is in the range of 0 to 44
    End If
    The count will stop the count value at 45 keep it there until it is reset, if you want it to automatically roll over to 0 then add an Else If condition, considering the relative simplicity of this I would have thought you could have come up with the solution yourself.

    If you have not already done so I strongly recommend installing the latest version of the compiler as the manual is very well organised and reading the sections on...
    Compiler Overview
    Mathametical Operations & Functions
    Comparison and Loop commands
    General Proton Basic commands and
    Interrupt directive
    as well as looking at some of the sample programs to give you a better understanding of the available commands and how to use them as you should be able to find such simple solution on your own.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    118
    Thumbs Up
    Received: 105
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    my code does not work.INTIME increases automatically though the portd.0 is low.

    Device = 16F877A
    Xtal = 16
    Include "MODEDEFS.BAS"
    All_Digital = True
    Declare LCD_DTPin = PORTB.4
    Declare LCD_RSPin = PORTB.2
    Declare LCD_ENPin = PORTB.3
    Declare LCD_Interface = 4
    Declare LCD_Lines = 4
    Declare LCD_Type = 0






    Dim intime As Byte
    Dim inset As Byte




    TRISB=0
    Input PORTD.1
    Input PORTD.0
    Input PORTC.3
    Input PORTC.2
    Output PORTA.0
    Output PORTA.1
    Output PORTA.2


    inset=0
    intime=0
    main:
    If PORTD.1=0 Then GoTo injectionset


    injectionset:
    If inset < 60 Then
    inset=inset + 1
    EndIf


    If PORTD.0=0 Then Inc intime
    If inset = intime Then PORTA.0=0
    DelayMS 1000




    Print At 1,7,Dec2,inset
    Print At 1,1,"IN=",Dec2,intime


    GoTo main


    Is there any other way for writing this program.
    Last edited by amod; 4th April 2019 at 18:53.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    481
    Thumbs Up
    Received: 40
    Given: 7
    Total Downloaded
    3.26 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    intime will increase while PortD.0 is low because that is what you have told it to do
    Code:
    If PORTD.0=0 Then Inc intime
    If you meant to say intime is increasing while PortD.1 is low and it should not, that is because you have placed injectionset immediately after your Goto command. Consequently, your code would work the same if the Goto instruction was not there because injctionset is the next instruction and no code is being jumped over. I think you need to re-arrange you code to this...
    Code:
    If PORTD.1=0 Then GoTo injectionset   'Do not execute increment intime code if PortD.1 = 0
    
    'Increment intime (only executed when PortD.1 = 1 & PortD.0 = 0)
    If PORTD.0=0 Then Inc intime 
    If inset = intime Then PORTA.0=0
    
    'Increment inset (runs every program loop regardless of the state of PortD.1)
    injectionset:
    If inset < 60 Then
    inset=inset + 1
    EndIf
    
    DelayMs 1000  'Wait 1 second
    However, if you do it this way the injection set code would execute every program loop and intime would not be incremented if both PortD.1 and PortD.0 are low at the same time is that what you wanted to do?

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Testing Bits of a register.
    By pic-ignorant in forum The Lounge
    Replies: 2
    Last Post: 16th May 2017, 17:36
  2. Any in the mood to do some beta-testing?
    By hadv215 in forum hadv215's Feedback Forum
    Replies: 0
    Last Post: 14th December 2016, 12:50
  3. CE Marking / Mains Testing
    By rpm26 in forum The Lounge
    Replies: 4
    Last Post: 9th February 2013, 16:45
  4. Debugging/Testing/Emulating
    By t0pP8uZz in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 5th November 2009, 20:23
  5. PCB Trace Testing
    By ohararp in forum The Lounge
    Replies: 1
    Last Post: 20th November 2007, 18:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts