Raspberry pi camera triggered via codesys plc program

lesnyulak
2015-02-27
2015-02-27
  • lesnyulak - 2015-02-27

    Hello forum users

    I have just successfully configured a one wire connection to a ds18b20 one wire sensor and can read the temperature in my plc program, and now I'm inspired to get the pi camera working.

    I can easily go to the command line in the pi and type:

    raspistill -o cam.jpg

    And the camera will take a pic and save it under that file name in the root directory. Then I can use an FTP utility like FileZilla to view the file remotely which is all I need to do.

    See attached screenshots for more detail

    How can I trigger the camera from the plc program?

    Thanks!

    IMG: image.jpg

    IMG: image.jpg

     
  • eschwellinger

    eschwellinger - 2015-02-27

    Hi,

    there is an example in the delivery/package:
    "c:\Users\<yourwindowsusername>\CODESYS Control for Raspberry PI\2.1.0.0\Camera.project" </yourwindowsusername>

    if you need a Stream:

    "c:\Users\<yourwindowsusername>\CODESYS Control for Raspberry PI\2.1.0.0\CameraStream.project"
    for the Stream you need additional some apt-get install on the linux side.
    Check:
    "c:\Users\<yourwindowsusername>\CODESYS Control for Raspberry PI\2.1.0.0\RaspberryPI_en.pdf"
    for details... attention if you activate the stream.. raspistill reports an error you need to stop the cam stream to be "raspistill enabled" again</yourwindowsusername></yourwindowsusername>

    this could either done by the webside (http://piIPAddress) or by the following commands:
    cd RPi_Cam_Web_Interface/
    ./RPi_Cam_Web_Interface_Installer.sh stop
    ./RPi_Cam_Web_Interface_Installer.sh start

    BR
    Edwin

     
  • lesnyulak - 2015-02-27

    Oh that's embarrassing... I didn't even know those demo programs were stored there!

    My code was almost identical... See attached. Only difference is I included the command "raspistill" before -o file name.jpg... Also didn't toggle the trigger back off after turning it on.

    Can you tell me where the file will get stored on the pi?

    Thanks

    IMG: image.jpg

     
  • eschwellinger

    eschwellinger - 2015-02-27

    Hi,

    you could get it by the CODESYS filebrowser:

    the directory is /root/

    BR
    Edwin

    IMG: FileBrowser.jpg

     
  • lesnyulak - 2015-02-27

    Wow... Very interesting

    If i do a "find / -name cam.jpg 2>/dev/null" from the pi prompt the file "cam.jpg" doesn't show up, even though from what I've read that should search the entire system.. Yet when I go to the file browser as you suggest, there it is!

    Yay!

    Thanks for your help Edwin... That's really cool stuff

    Les

    IMG: image.jpg

     
  • lesnyulak - 2015-02-27

    Sorry... One more dumb question... Why cannot I not access that file?

    If I double click nothing happens, and the << or >> arrows between the host and runtime windows appear greyed out... Is there something I need to do to enable access to files in that directory?

    Les

    IMG: image.jpg

     
  • eschwellinger

    eschwellinger - 2015-02-27

    Hi,
    select the file in the right windows (plc) ->the jpg.
    then '<<' should be not greyed, move it to the left window (there you need to specify a directory with write access on your Windows machine)

    BR
    Edwin

     
  • lesnyulak - 2015-02-27

    Yes!

    That was it... A valid directory (ie the root of c:) needed to be selected in the left hand pane, then the << button became un greyed and I could move the pic from the pi to my hard drive.

    Thanks once again Edwin!

     

Log in to post a comment.