RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Spurious Readings - Help Requested

Tue May 24, 2016 8:30 am

Code: Select all

# RDS Program to determine if light is falling on Photo Transistor
# Using BPW85 PhotoTransistor
# PhotoTransistor (PT) connected as follows
# Collector connected to 3.3v
# Emitor connected to 0v via a 10k resistor
# Output taken from where the PT connects to the resistor ...
# ...and connected to GPIO18 (actual Pin 12 on the GPIO strip)


import RPi.GPIO as GPIO
from datetime import  *
from time import time
import mikezlcd
import smtplib
from email.mime.text import MIMEText


GPIO.setmode(GPIO.BCM) # previously I used BOARD, rather than BCM
GPIO.setup(18, GPIO.IN) # when using BOARD the port was number 12, now 18
lcd = mikezlcd.lcd_module(2004, 17, 27, 25, 24, 23,22)

#Define Variables
L1=""
L2=""
L3=""
L4=""
tempstr = ""
tempint = 0

detect = 0
detct = 0
kwatt = ""
kilowatt = 0
wcount = 0
mcount = 0
cnt = 0
timenow = time()
detected = 0
lastpulse = 1  # was zero
starttime = 0
averagee = 0
shortest = 999
email_threshold = 5000
lpulse = ""
subjectt = "Subject of message sent to gmail"
messagee = "A variable for a message sent to gmail"
timeunit = ""
kwhr = 0


def send_email(subjectt,messagee):
    USERNAME = "**********"
    PASSWORD = "*****" 
    #MAILTO  = "******"
    MAILTO  = "******"

    #msg = MIMEText('This is a test of an email from Raspberry Pi')
    msg = MIMEText(messagee)
    msg['Subject'] = subjectt
    msg['From'] = USERNAME
    msg['To'] = MAILTO

    server = smtplib.SMTP('******')
    server.ehlo_or_helo_if_needed()
    server.starttls()
    server.ehlo_or_helo_if_needed()
    server.login(USERNAME,PASSWORD)
    server.sendmail(USERNAME, MAILTO, msg.as_string())
    server.quit()



print (int(timenow))   #This prints the integer date since Epoch (1/1/1970)

daynumber = datetime.now().strftime( '%j')
minutenumber = datetime.now().strftime( '%M')

#input_value = GPIO.input(18)


while True:
    input_value = GPIO.input(18)
    
        
    # Check if Day number has changed to reset counter
    if daynumber != datetime.now().strftime( '%j'):
       
     detect = 1
     
    if input_value == False:
        if detect > 0:
         today = datetime.now()
         fullday = today.strftime( '%A')
         shortday = today.strftime( '%a')
                  
         if detect == 1:
           starttime = int(time())
         
         
         if detect >=2:   
          timenow = time()   
          lastpulse = timenow - detected
          lpulse = '{:0.2f}'.format(lastpulse)

          if detect % email_threshold == 0: # threshold defined in variables
           send_email(str(detect) + " units today","Current Rate " + str(kwhr) + "kw/hr" + '\n' + "Last Rate" + '\n' + "Previous Rate")
           print ("email sent")
          averagee = '{:0.2f}'.format((timenow - starttime)/(detect-1))
         kwatt = '{:0.3f}'.format(detect/1000)
         

         # Prepare Data to send to LCD
         L1 = (fullday + ": " + kwatt + "kw").center (20," ")
         if lastpulse > 60:
             lpulse = (str(int(lastpulse//60))) + "min " + (str(int(lastpulse%60))) + "sec"
             L2 = ("Rate: " + lpulse).center (20," ")
         else:
             L2 = ("Rate: " + lpulse + "secs").center (20," ")
         L3 = ""
         kwhr = ('{:0.3f}'.format(3.600/(lastpulse)))  
         L3 = ("Last: "+ str(kwhr)+"kw/hr").center (20," ")
         #L4 = (("Average: " + str(averagee)) + "secs").center (20," ")
         L4 = ("email at " + (str(email_threshold)) + " units").center (20," ")
         

         # Send Output to Screen
         #print (detect," ",end="")
         print (detect,end="")
         print ('\t',today,end="")
         #print ('\t',today.hour,":",today.minute,":",today.second,sep='',end="")
         print ('\t',L2,str(kwhr)+"kw/hr")
         

         # Send Output to LCD                     
         lcd.disp(0,0,L1)
         lcd.disp(0,1,L2)
         lcd.disp(0,2,L3)
         lcd.disp(0,3,L4)
         
        else:
         print ("Program started")
         
         #send_email("Program Started",str(datetime.now()))
        detect = detect + 1
        daynumber = datetime.now().strftime( '%j')
        detected = (timenow)
        
                
        while input_value == False:
            input_value = GPIO.input(18)

I have been using the above code to display the output of my Solar Panels for the last few months. In general, it works very well but a number of times a day (not at any particular times) it starts to count non-existent pulses. This may very well be because of the way it is wired up, because from the Raspberry Pi, which is located upstairs, I use a length of about 20 metres of network cable to connect to the Photo Transistor. In view of the fact that this works well most of the time, I do not really want to have to change the wiring.

It also sends an email to me at a frequency determined by the program (currently set at 5000 units) and this is a part of the program I would like to change as well at sometime in the future so that I can email the Pi and get it to give me the status at that point in time. But that can come later!

The way I would like to overcome the additional spurious pulses is to make a change the my program but I cannot fathom out how to do it. I am sure that the change will be very simple but I don't know where to put it in my program. The panels are rated at 4Kw, so that is the absolute maximum they can ever output. As can be seen in my code, I display the output on an LCD display and Line 3 of my display (variable L3) shows the current output. My idea would be to ignore any pulses that give a current output in excess of (say) 3.9kw.

I would appreciate any help.

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Tue May 24, 2016 9:01 am

Is your sensor being triggered by sunlight or reflected sunlight?
I have a similar setup using a TAOS device stuck to a meter with tac but light seems to get in through the meter display panel and casues occasional spurious triggers. One day I'll box it all in to keep it in the dark :)

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Tue May 24, 2016 12:11 pm

@fruit-uk
Thank you for your reply.
I don't think so. My meter is in an under the stairs cupboard and like you, it is held against the flashing LED by blutac. I have tried flashing a light at the side of it and it does not result in counts, so I think it must be interference from somewhere along the line, hence the request for help with the code to just blank out anything that is clearly wrong.
When it does go wrong, it is registering a count about every 0.2 of a second, whereas the capacity limit of the Solar Panels should result in nothing less than about 0.9 seconds.
I just need a statement somewhere in my code that ignores anything less than 0.9 seconds but I have so far been unable to work out where.

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Tue May 24, 2016 12:27 pm

Worth a try anyway:)

Sorry, I don't do python but seems to me that you need to store time value of pulse in a variable and check difference as a new pulse arrives.
You could use a delay loop but that's not very efficient

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Tue May 24, 2016 2:11 pm

@fruit-uk
A delay loop - I guess you mean put a loop in the code after a pulse has been received so that it does not check for another pulse until the delay has expired?

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Tue May 24, 2016 2:43 pm

Yes but that may block other things.

You are using 'daynumber = datetime.now().strftime( '%j')'
I'd guess there would be parameters for intervals smaller than a second even if it's just a fractional value of a second.
Store that value in a variable and check it as you do for 'if daynumber != datetime.now().strftime( '%j'):' within the while loop

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Thu May 26, 2016 9:45 am

Does anyone else have any other suggestions

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Spurious Readings - Help Requested

Thu May 26, 2016 1:52 pm

Is a 'pulse' counted as a high or a low. 20 metres of cable is some distance - are you confident that the levels received for both a high and a low are sufficient to register as they should at the pi's GPIO port? Also how are you monitoring the data - have you considered putting the Pi under the stairs with the photo tranny?
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

boyoh
Posts: 1370
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Spurious Readings - Help Requested

Thu May 26, 2016 3:36 pm

RDS wrote:

Code: Select all

# RDS Program to determine if light is falling on Photo Transistor
# Using BPW85 PhotoTransistor
# PhotoTransistor (PT) connected as follows
# Collector connected to 3.3v
# Emitor connected to 0v via a 10k resistor
# Output taken from where the PT connects to the resistor ...
# ...and connected to GPIO18 (actual Pin 12 on the GPIO strip)


import RPi.GPIO as GPIO
from datetime import  *
from time import time
import mikezlcd
import smtplib
from email.mime.text import MIMEText


GPIO.setmode(GPIO.BCM) # previously I used BOARD, rather than BCM
GPIO.setup(18, GPIO.IN) # when using BOARD the port was number 12, now 18
lcd = mikezlcd.lcd_module(2004, 17, 27, 25, 24, 23,22)

#Define Variables
L1=""
L2=""
L3=""
L4=""
tempstr = ""
tempint = 0

detect = 0
detct = 0
kwatt = ""
kilowatt = 0
wcount = 0
mcount = 0
cnt = 0
timenow = time()
detected = 0
lastpulse = 1  # was zero
starttime = 0
averagee = 0
shortest = 999
email_threshold = 5000
lpulse = ""
subjectt = "Subject of message sent to gmail"
messagee = "A variable for a message sent to gmail"
timeunit = ""
kwhr = 0


def send_email(subjectt,messagee):
    USERNAME = "**********"
    PASSWORD = "*****" 
    #MAILTO  = "******"
    MAILTO  = "******"

    #msg = MIMEText('This is a test of an email from Raspberry Pi')
    msg = MIMEText(messagee)
    msg['Subject'] = subjectt
    msg['From'] = USERNAME
    msg['To'] = MAILTO

    server = smtplib.SMTP('******')
    server.ehlo_or_helo_if_needed()
    server.starttls()
    server.ehlo_or_helo_if_needed()
    server.login(USERNAME,PASSWORD)
    server.sendmail(USERNAME, MAILTO, msg.as_string())
    server.quit()



print (int(timenow))   #This prints the integer date since Epoch (1/1/1970)

daynumber = datetime.now().strftime( '%j')
minutenumber = datetime.now().strftime( '%M')

#input_value = GPIO.input(18)


while True:
    input_value = GPIO.input(18)
    
        
    # Check if Day number has changed to reset counter
    if daynumber != datetime.now().strftime( '%j'):
       
     detect = 1
     
    if input_value == False:
        if detect > 0:
         today = datetime.now()
         fullday = today.strftime( '%A')
         shortday = today.strftime( '%a')
                  
         if detect == 1:
           starttime = int(time())
         
         
         if detect >=2:   
          timenow = time()   
          lastpulse = timenow - detected
          lpulse = '{:0.2f}'.format(lastpulse)

          if detect % email_threshold == 0: # threshold defined in variables
           send_email(str(detect) + " units today","Current Rate " + str(kwhr) + "kw/hr" + '\n' + "Last Rate" + '\n' + "Previous Rate")
           print ("email sent")
          averagee = '{:0.2f}'.format((timenow - starttime)/(detect-1))
         kwatt = '{:0.3f}'.format(detect/1000)
         

         # Prepare Data to send to LCD
         L1 = (fullday + ": " + kwatt + "kw").center (20," ")
         if lastpulse > 60:
             lpulse = (str(int(lastpulse//60))) + "min " + (str(int(lastpulse%60))) + "sec"
             L2 = ("Rate: " + lpulse).center (20," ")
         else:
             L2 = ("Rate: " + lpulse + "secs").center (20," ")
         L3 = ""
         kwhr = ('{:0.3f}'.format(3.600/(lastpulse)))  
         L3 = ("Last: "+ str(kwhr)+"kw/hr").center (20," ")
         #L4 = (("Average: " + str(averagee)) + "secs").center (20," ")
         L4 = ("email at " + (str(email_threshold)) + " units").center (20," ")
         

         # Send Output to Screen
         #print (detect," ",end="")
         print (detect,end="")
         print ('\t',today,end="")
         #print ('\t',today.hour,":",today.minute,":",today.second,sep='',end="")
         print ('\t',L2,str(kwhr)+"kw/hr")
         

         # Send Output to LCD                     
         lcd.disp(0,0,L1)
         lcd.disp(0,1,L2)
         lcd.disp(0,2,L3)
         lcd.disp(0,3,L4)
         
        else:
         print ("Program started")
         
         #send_email("Program Started",str(datetime.now()))
        detect = detect + 1
        daynumber = datetime.now().strftime( '%j')
        detected = (timenow)
        
                
        while input_value == False:
            input_value = GPIO.input(18)

I have been using the above code to display the output of my Solar Panels for the last few months. In general, it works very well but a number of times a day (not at any particular times) it starts to count non-existent pulses. This may very well be because of the way it is wired up, because from the Raspberry Pi, which is located upstairs, I use a length of about 20 metres of network cable to connect to the Photo Transistor. In view of the fact that this works well most of the time, I do not really want to have to change the wiring.

It also sends an email to me at a frequency determined by the program (currently set at 5000 units) and this is a part of the program I would like to change as well at sometime in the future so that I can email the Pi and get it to give me the status at that point in time. But that can come later!

The way I would like to overcome the additional spurious pulses is to make a change the my program but I cannot fathom out how to do it. I am sure that the change will be very simple but I don't know where to put it in my program. The panels are rated at 4Kw, so that is the absolute maximum they can ever output. As can be seen in my code, I display the output on an LCD display and Line 3 of my display (variable L3) shows the current output. My idea would be to ignore any pulses that give a current output in excess of (say) 3.9kw.

I would appreciate any help.
Using software to correct a hardware, problem is not always the answers.
If you are not sure of the problem... How do you know they are non existence
pulses, only a comparison test will tell you this, You will have to go through
The process of elimination to find the problem, only you can do that.

1 Is it transient noise

2, Try re-routing the long cable.

3 What voltage are you using for the LDR circuit.
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

MarkTF
Posts: 302
Joined: Tue Mar 03, 2015 4:59 pm

Re: Spurious Readings - Help Requested

Thu May 26, 2016 4:34 pm

# PhotoTransistor (PT) connected as follows
# Collector connected to 3.3v
# Emitor connected to 0v via a 10k resistor
# Output taken from where the PT connects to the resistor ...
# ...and connected to GPIO18 (actual Pin 12 on the GPIO strip)
Presuming the issue is noise pick up on the cable run, you should be able to improve circuit noise immunity by reducing the circuit impedance. A simple thing to try would be to try lower resistor values, maybe 1k if there is enough light on the photo transistor. Whether that works depends upon the characteristics of your spurious noise. Better would be to follow the photo transistor with a proper differential line driver and receiver (RS-422 / RS-485) on either end of your line.

Is there any other signal running on other connectors of this cable that might produce cross talk?

boyoh
Posts: 1370
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 1:55 pm

This will have lower impedance and better noise suppression

---------------( LED-----
---------------vvvvvvv--------
5v+-------( c P/T e )------( 500R )--------( a opto k )----0v--
-- ------------------------------------------------------vvvvvvv------
3.3v+--------------------------------------------( c opto e)----GPIO---10k--0v
-------------------------------------------------------------------------------P/U/R--
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 2:20 pm

texy wrote:Is a 'pulse' counted as a high or a low. 20 metres of cable is some distance - are you confident that the levels received for both a high and a low are sufficient to register as they should at the pi's GPIO port? Also how are you monitoring the data - have you considered putting the Pi under the stairs with the photo tranny?
Texy
texy, Thank you for your reply.
To try to answer you questions:
- As far as I am aware, a pulse is counted as a low. That is certainly what I intended when I wired it up as described in the statements at the top of my program in my original post.
- I am confident that the 'legitimate' pulses are correctly received.
- My program monitors the data, both on the screen and on an LCD.
- I had considered putting the pi under the stairs with the Photo Transistor but discounted this because I wanted the ability to change my program easily, so I opted to keep the Pi, PSU, Mouse and Screen where I can access them.
Last edited by RDS on Fri May 27, 2016 2:30 pm, edited 1 time in total.

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 2:29 pm

boyoh wrote:
Using software to correct a hardware, problem is not always the answers.
If you are not sure of the problem... How do you know they are non existence
pulses, only a comparison test will tell you this, You will have to go through
The process of elimination to find the problem, only you can do that.

1 Is it transient noise

2, Try re-routing the long cable.

3 What voltage are you using for the LDR circuit.

@ boyoh, Thank you for your reply.
I can understand that a S/W solution would not be ideal but it was the only way I could think of to solve the problem.
To answer your questions:
1) The problem seems worse when we are using some other electrical device in the house, so I assume it is noise. Transient? I don't know.
2) Not really an option because I have made use of existing network wiring in my house, that is not connected to anything else though, at either end.
3) The Photo Transistor uses 3.3v from the Pi and is connected as described in the program notes at the start of my initial post.

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 2:34 pm

MarkTF wrote:
# PhotoTransistor (PT) connected as follows
# Collector connected to 3.3v
# Emitor connected to 0v via a 10k resistor
# Output taken from where the PT connects to the resistor ...
# ...and connected to GPIO18 (actual Pin 12 on the GPIO strip)
Presuming the issue is noise pick up on the cable run, you should be able to improve circuit noise immunity by reducing the circuit impedance. A simple thing to try would be to try lower resistor values, maybe 1k if there is enough light on the photo transistor. Whether that works depends upon the characteristics of your spurious noise. Better would be to follow the photo transistor with a proper differential line driver and receiver (RS-422 / RS-485) on either end of your line.

Is there any other signal running on other connectors of this cable that might produce cross talk?
@MarkTF
Thank you for your reply.
- It does appear that the issue is noise interference, so I have started to look into the Transmit and receive components you describe (I am not sure how they would be used though)
- There are no other signals running through the cable.

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Spurious Readings - Help Requested

Fri May 27, 2016 2:38 pm

RDS wrote:
texy wrote:Is a 'pulse' counted as a high or a low. 20 metres of cable is some distance - are you confident that the levels received for both a high and a low are sufficient to register as they should at the pi's GPIO port? Also how are you monitoring the data - have you considered putting the Pi under the stairs with the photo tranny?
Texy
texy, Thank you for your reply.
To try to answer you questions:
- As far as I am aware, a pulse is counted as a low. That is certainly what I intended when I wired it up as described in the statements at the top of my program in my original post.
- I am confident that the 'legitimate' pulses are correctly received.
- My program monitors the data, both on the screen and on an LCD.
- I had considered putting the pi under the stairs with the Photo Transistor but discounted this because I wanted the ability to change my program easily, so I opted to keep the Pi, PSU, Mouse and Screen where I can access them.
Is the network cable still intact or did you remove the connectors to gain access to the wiring?
If you put the pi under the stairs you could still access it remotely using the same network cable via SSH. This would eliminate any cross talk on the signalling from the tranny, if that is indeed what is causing it.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 2:47 pm

boyoh wrote:This will have lower impedance and better noise suppression

---------------( LED-----
---------------vvvvvvv--------
5v+-------( c P/T e )------( 500R )--------( a opto k )----0v--
-- ------------------------------------------------------vvvvvvv------
3.3v+--------------------------------------------( c opto e)----GPIO---10k--0v
-------------------------------------------------------------------------------P/U/R--
@boyoh
Thank you for your second reply.
I am very encouraged by how simple this looks but I would appreciate more detail to understand it.
The way I read your diagram is as follows:
The LED on my Solar Meter shines on my Photo Transistor, this appears to be connected to some form of opto device, then on the 0v. I am assuming that the second row of vvvvvvv represents my 20 metre cable and this is connected to a second opto device and onto my GPIO pin. I don't know what the P/U/R represents at the end.
What components are represented by the 2 opto references?
Please accept my apologies if I have all of this, totally wrong!

boyoh
Posts: 1370
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 3:56 pm

RDS wrote:
boyoh wrote:This will have lower impedance and better noise suppression

---------------( LED-----
---------------vvvvvvv--------
5v+-------( c P/T e )------( 500R )--------( a opto k )----0v--
-- ------------------------------------------------------vvvvvvv------
3.3v+--------------------------------------------( c opto e)----GPIO---10k--0v
-------------------------------------------------------------------------------P/U/R--
@boyoh
Thank you for your second reply.
I am very encouraged by how simple this looks but I would appreciate more detail to understand it.
The way I read your diagram is as follows:
The LED on my Solar Meter shines on my Photo Transistor, this appears to be connected to some form of opto device, then on the 0v. I am assuming that the second row of vvvvvvv represents my 20 metre cable and this is connected to a second opto device and onto my GPIO pin. I don't know what the P/U/R represents at the end.
What components are represented by the 2 opto references?
Please accept my apologies if I have all of this, totally wrong!
I will explain the operation of the Opto Isolator circuited

1 The vvvvvv is the light beam between the pulse led and the Photo Transistor.

2 The vvvvvv is the I/R signal between the Opto transmitter and receiver .

3 P/U/R ( Pull Up Resistor ) To set the GPIO to working level '

4. If the in/put signal is a active 1( high) you connect the 10k to 0v-

5 If the in/put signal is a active 0 ( low) you connect the 10k to 3.3v+ Rail.

6 If the GPIO is not set to a working level it is called Floating it will neither sink or source

Regards boyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 6:18 pm

@boyoh
Thank you, I think I understand.
Which end of my 20 metre cable does the opto device go at, the photo transistor end or the Raspberry Pi end?
I have been looking at opto isolators. Would a 4N35 be suitable?

boyoh
Posts: 1370
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 7:22 pm

RDS wrote:@boyoh
Thank you, I think I understand.
Which end of my 20 metre cable does the opto device go at, the photo transistor end or the Raspberry Pi end?
I have been looking at opto isolators. Would a 4N35 be suitable?
The 4n 35 will be ok

The opto isolator at the Pi end

(c-----------cable-------------------------- 5v+ ( Pi )
P/T
(e-----------cable-----------------------( 500r )---( a opto k )---0v-( Pi )
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Fri May 27, 2016 9:26 pm

@boyoh
Thank you very much.
I hope to get one tomorrow.
I will post the results

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Sat May 28, 2016 6:42 pm

@boyoh
I have picked up some 4N35 opto isolators today.
Sorry to be a nusiance, another couple of questions about your diagram.
- What does P/T stand for?
- What does 'a opto k' mean. (I assumed it was where the connections onto the opto were made, i.e. a to the 500R resistor and k to 0v on the Pi, but the connections on the output side of the 4N35 opto are B,C and E)

User avatar
rpdom
Posts: 15897
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Spurious Readings - Help Requested

Sat May 28, 2016 7:42 pm

P/T would be the connections to the Phototransistor.

a is the Anode of the LED in the opto (+ve) and k is the Cathode (-ve).

You only need to use the C (collector) and E (emitter) of the opto's output. The B (base) connection isn't used.

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Sat May 28, 2016 9:12 pm

@rpdom
Thanks - I can't believe I didn't get Photo Transistor!
Last edited by RDS on Sun May 29, 2016 8:53 am, edited 1 time in total.

boyoh
Posts: 1370
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Spurious Readings - Help Requested

Sat May 28, 2016 10:57 pm

rpdom wrote:P/T would be the connections to the Phototransistor.

a is the Anode of the LED in the opto (+ve) and k is the Cathode (-ve).

You only need to use the C (collector) and E (emitter) of the opto's output. The B (base) connection isn't used.
Thanks for explaining the P/T & the ( a k ) to RDS
Regards boyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

RDS
Posts: 738
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Spurious Readings - Help Requested

Mon May 30, 2016 10:14 am

I have realised that when the 'interference' occurs, it regularly causes a pulse every 0.20 seconds but if I place my hand over the Pi (not touching anything), it reverts to just detecting 'correct' pulses.

This method of removing the interference, is 100% consistently repeatable but I now have no idea what causes the interference in the first place. 2 days ago, my program ran virtually all day without any problems or interference.

Return to “Python”