Matt B

Members
  • Content Count

    15
  • Joined

  • Last visited

About Matt B

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Is there a easy way to shorten the number from scope. Example I get a 88.23456987655, I would like to capture or round to 88.23? @attila Awesome... How would I implement this into a array. For example below is the code. "rgusw" is the array I would like to round.
  2. Is there a easy way to shorten the number from scope. Example I get a 88.23456987655, I would like to capture or round to 88.23?
  3. Above the measured value of NegWidth always displays the correct reading. Below is the desired result. I get 6 pulses in each direction. Below is the result after running a few sensors. Once the data gets like this below the fix is cycling the scope off and back on. SensorTestingA_Updated.js I found that if I run the test and print out the usw & usw_B result (Not Averaged) it has been correct all morning. I do not know if that will help us figure the issue out. Thank you again for the help.
  4. Hey @attila thank you for the reply. Today I worked to figure this issue out. I did find one issue that I could resolve. When I notice my numbers wrong, I would turn the scope off and back on. That would fix my data every single time. I tried to turn the scope off at the end of my script, but I have not been able to successfully turn it back on using my script, but I am working on that. Do you have any ideas? I was able to stop the scope and restart it before the next cycle. So far everything is working well. Matt
  5. @attila Hey Thank you helping with my project a month ago.. Below is the code that you helped me with. Basically when the scope is triggered I average the number of readings that are given. It seems that when the data is averaged from the scope I am getting weird data within the array. for example I may get a quanity of 9 numbers and most of them are around 44.3, 44.9 or 45.23... Those numbers would be ok. But within the same averaged array I am getting numbers that are 80 and 60 and I am not sure how. Thank you for the help. var rgusw = [] var cw = 0 var sumusw = 0 var SensorA_CC_Tested = 0 //Sets Sensor Test Value to zero before test var SensorStep = 1 //Sets the clockwise test into action -- Sets to zero before test // This keeps the script running all the time. (while Statement) while(SensorStep <= 3 && Scope1.State.running() && Logic1.State.running()){ for(var i = 0; i < 8 && Scope.wait(); i++){ var usw = Scope.Channel1.measure("NegWidth")*1e6 // us rgusw.push(usw) // array sumusw += usw cw++ } //print(rgusw) //Uncomment to print all averaged data var uswavg = sumusw/cw if(SensorStep ==1){ SensorA_CC_Tested = "1"; print("Counter Clockwise Average:",+uswavg+" uS") Is it possible to average only the numbers that are between high and low number or use the measured value that the Scope displays. The Scope measurement for Negwidth is perfect, but the data in the averaged array varies too much for whatever reason.
  6. Thanks @attila I am using Terminal program to check the data output. Im using a USB to Serial adapter to the pc. Looks like the problem was the polarity. Once I changed it to inverted the data started working correctly. Thank you for the help!! Matt
  7. Hi @attila I adjusted my code to convert to text and I am not getting the desired text. Do you have any ideas?
  8. Hello @attila I have my project working well. Now I am trying to send my results via serial using UART. I am seeing data, but I do not know how to decode it. I am using Terminal to test it and I am receiving junk. Here is the snippet of the Logic and my code. Scope1.run(); StaticIO.run(); Protocol.run(); var rgusw = [] var cw = 0 var sumusw = 0 var Sensor1LL_CC = 38 //Sensor A Counter Clockwise Lower Limit +-7 var Sensor1UL_CC = 52 //Sensor A Counter Clockwise Upper Limit +-7 var SensorA_CC_Tested = 0 //Sets Sensor Test Value to zero before test var SensorStep = 1 //Sets the clockwise test into action -- Sets to zero before test StaticIO.Channel0.DIO0.value = 0 //Sensor A Passed -- Set to zero beofre test StaticIO.Channel0.DIO1.value = 0// Sensor A Failed -- Set to zero before test while(SensorStep <= 3 && Scope1.State.running() && StaticIO.State.running()){ for(var i = 0; i < 9 && Scope.wait(); i++){ var usw = Scope.Channel1.measure("NegWidth")*1e6 // us rgusw.push(usw) // array sumusw += usw cw++ } //print(rgusw) //Uncomment to print all averaged data var uswavg = sumusw/cw if(uswavg > Sensor1LL_CC && uswavg < Sensor1UL_CC){ SensorA_CC_Tested = "1"; print("Sensor Upper Limit: ",+Sensor1UL_CC+" uS") print("Average:",+uswavg+" uS") print("Sensor Lower Limit: ",+Sensor1LL_CC+" uS") print("Sensor Counter Clockwise Tested: "+SensorA_CC_Tested) SensorStep = "2"; } else{ print("Failed") print("Sensor Counter Clockwise Tested: "+SensorA_CC_Tested) print("Average:",+uswavg+" uS") StaticIO.Channel0.DIO1.value = 1// Sensor A Failed }; if(SensorStep ==2){ var rgusw_B = [] var cw_B = 0 var sumusw_B = 0 var Sensor1LL_C = 76 //Sensor A Clockwise Lower Limit +-14 var Sensor1UL_C = 104 //Sensor A Clockwise Upper Limit +-14 var SensorA_C_Tested = 0 //Sets Sensor Test Value to zero before test for(var i = 0; i < 9 && Scope.wait(); i++){ var usw_B = Scope.Channel1.measure("NegWidth")*1e6 // us rgusw_B.push(usw_B) // array sumusw_B += usw_B cw_B++ } //print(rgusw_B) //Uncomment to print all averaged data var uswavg_B = sumusw_B/cw_B if(uswavg_B > Sensor1LL_C && uswavg_B < Sensor1UL_C){ SensorA_C_Tested = "1"; print("Sensor Upper Limit: ",+Sensor1UL_C+" uS") print("Average:",+uswavg_B+" uS") print("Sensor Lower Limit: ",+Sensor1LL_C+" uS") print("Sensor Clockwise Tested: "+SensorA_C_Tested) SensorStep = "1"; StaticIO.Channel0.DIO0.value = 1 //Pass both directions turn on output to plc // *****Protocol Code below for comms to PLC***** //Code below is for data Collections if(!('Protocol' in this)) throw "Please open the Protocol tool"; Protocol.Mode.text = "UART" // make sure UART tab is selected Protocol.UART.SendArray([Sensor1UL_CC,uswavg,Sensor1LL_CC,SensorA_CC_Tested,Sensor1UL_C,uswavg_B,Sensor1LL_C,SensorA_C_Tested]) } else{ print("Failed") print("Average:",uswavg) print("Sensor Clockwise Tested: "+SensorA_C_Tested) StaticIO.Channel0.DIO1.value = 1// Sensor A Failed } } } * Here is what the output of the script looks like If I understand correctly, it looks like I will need a UART to RS232 Converter. Is this right?
  9. Hello @attila Is it possible to re-activate the script again after it has ran automatically? Thanks, Matt
  10. I have another question. Below is the output of the script. Since it is not in a array, I am having issues trying to average the two different readings below. I assume that there is a JavaScript function to do this? Thanks, Matt
  11. The reason I have negative voltage readings is I working in a noisy environment. We have multiple inverter drives running sporadically all day long. I swapped my scope leads and inverted my trigger and voltage to get the pulse. I did this to get rid of the noise. Before I made this change it would trigger automatically in ambient air because of the voltage trigger. I was able to get the measured Pulse Width this time. I had to multiply to get the decimal in the correct spot. Thanks to everyone for the help. Matt
  12. I tried to setup the scope like you did above and I didn't get the same results. More than likely my issue is the sensor. This sensor is used for speed. I have a trigger as 940mv and this is based on the resister I have hooked up. Once I trigger the sensor I see one pulse and that pulse width will be either 45 or 90 us for a good sensor. When I wired the StaicIO to the sensor to use logic to get the pulse width, the values that I was seeing in Logic was wrong. It was not the same as the scope reading. Is there another way to get "NegWidth" into a variable so I can use it with scripting? My goal is to send output from discovery 2 to a PLC for pass/fail based on Pulse width. measurements.
  13. Are you saying I do not have access to NegWidth measured value with the latest copy of the software?
  14. I do not think that will work for this application. I am actually testing a sensor. I am using the trigger to get the pulse from the sensor. The pulse responds differently to rotation in the clockwise/cc direction. I am measuring that Pulse width and checking to make sure it is in tolerance. If it is within tolerance I will activate StaticIO output. If I could get the measurement of the NegWidth or PosWidth from the Scope into a variable in Script, I may be able figure this out.
  15. Hello, I am having a issue writing a script to turn on a digital output for pulse width measurement. I have two measurements. One has a pulse width of about 45us and the other around 80us. I have tried to display the Pulse Width using script and I am having issues. I would like to use the pulse width measurements and check it for tolerance. If measurement is good, turn on output. Any help would be appreciated. Thanks, Matt