Matt B

Newcomers
  • Content Count

    10
  • 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. 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
  2. Hi @attila I adjusted my code to convert to text and I am not getting the desired text. Do you have any ideas?
  3. 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?
  4. Hello @attila Is it possible to re-activate the script again after it has ran automatically? Thanks, Matt
  5. 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
  6. 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
  7. 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.
  8. Are you saying I do not have access to NegWidth measured value with the latest copy of the software?
  9. 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.
  10. 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