mcjMPU6050
________________________________________________________________________
Introduction
________________________________________________________________________
This is a kit of software allowing you to control objects in a Daz Studio scene using an Arduino equipped with sensors
This release is designed for the MPU-6050 sensor board but the communication protocol is easy to implement
so if you are am Arduino programmer, you could adapt it to other sensors including potentiometers and switches
________________________________________________________________________
Pre-Requisites
________________________________________________________________________
you worked with Arduinos or electonic hardware before, so you can safely wire a sensor to an arduino
a PC computer since the bridge between arduino's COM port is an .exe
________________________________________________________________________
Installation
________________________________________________________________________
1 - install the MPU6050_tockn Arduino library by tockn which will let the arduino communicate with the MPU-6050
https://github.com/tockn/MPU6050_tockn
2 - download and install mcjMPU6050.ino ( by me ) on your arduino uno -
it can be found in the attachment section at the bottom of this web page
3 - download MCJCOMMTTY08262018.zip it contains mcjComtty.exe A PC/DOS program known as a "terminal"
It is the communication bridge between the Arduino and DazStudio
We suggest you unzip it in YourDazContentLibrary/scripts/mCasual
because by default that's where mcjMPU6050.dsa will expect to find it
but you can place it where you please!
MCJCOMMTTY08262018.zip can be found in the attachment section at the bottom of this web page.
MCJCOMMTTY08262018.zip also contains mcjCommtty.cpp the source code,
which is a very lightly modified version of the very old ( 1996) program CommTTY by Robert Mashlan
http://nersp.nerdc.ufl.edu/~esi4161/files/commtty.c
4 - download mcjMPU6050.zip It contains mcjMPU6050.dsa;
a Daz Studio script which sends, receives and displays data to/from the Arduino
through the mcjCommTty.exe bridge. Unzip it in a Daz Studio Content folder.
Typically it means:
c:\program files\daz\studio\contents
or
C:\Program Files (x86)\DAZ\Studio\content
or
C:\Users\YOURUSERNAME\Documents\DAZ 3D\Studio\My Library\
if installed properly, mcjMPU6050.dsa will be accessible in Daz Studio in the contents tab as
studio/scripts/mcasual/
or
My Library/scripts/mCasual
________________________________________________________________________
Version History
________________________________________________________________________
August 26th 2018 6:48PM - Release
________________________________________________________________________
Wiring
________________________________________________________________________
i used this wiring for my GY-521 module
source: https://42bots.com/tutorials/arduino-script-for-mpu-6050-auto-calibration/
________________________________________________________________________
Instructions
________________________________________________________________________
make sure the arduino is running mcjMPU6050.ino
In your Daz Studio Scene, select the object(s) which will be controlled by the mpu-6050
launch the mcjMPU6050.dsa Daz Script
set the com port appropriately and the baud rate to 57600 ( because the arduino sketch uses that baudrate )
if it's not already done, press the "Select Server" button and specify the location of mcjComtty.exe
press the "Start Server" button
the channel list on the left will be populated with the names of the sensor channels
The Server/Client Linking section
Now lets connect some sensor channels to the Gabrielle's head transforms
click-select the "AngX" server channel, click-select the "Head Side-side" client channel
The mpu6050 gives us this angle in degrees and the car's XRotate channel is in degrees
since the side-side rotation of the sensor made the head swing too widely, i applied a 0.5 factor to it
the "Add" factor could let you for example add 90 degrees to the sensor's reading before applying it to the head rotation
click on the "Add Link" button
Note that the correct "Server channel" and the correct "Client Channel" and the correct "Server/Client Link"
must be selected when you use the "Modify" or "remove" button
You can save/load your server-client links as a text file
note that the script will not accept to load links for the Head when the selected object is not a Head
As you can see below when the Arduino starts
it will transmit the names of the properties that will follow,
this is called the "HEADERS" message
then the next transmissions will be the property values, separated by TAB characters with an "eol\n" delimiter at the end of each record
this is called the "DATA" messages
If the "Server Channels" list does not fill up, you can press the Arduino's reset button or the script's "GetHeaders" button
By default the sampling rate is 10 per second ( 100ms intervals ) but you can adjust this with the "period (ms)" slider.
Also by default the Arduino doesn't send data samples until you click the "One Sample" button or you check-mark the "Periodic" checkbox
The Record buttons
using the "no feedback" button will record the motion data, but it wont be visible on screen during the capture
this ensures the optimal sample rate
using the "with live feedback" button will record the motion data and you will see the animation on screen during the capture
________________________________________________________________________
Notes
________________________________________________________________________
using a sampling period lower than the desired sampling period
may allow you to get up to 120 samples per second.
but dont go too low, else the arduino will not have idle time to check
your commands. a sampling period of 10ms was ok
The arduino transmits 14 parameters, if only the last 3 interest you
then in mcjmpu6050.ino comment out the lines for those parameters
Be careful not to comment out the following lines. Also make sure that
if you comment out a DATA item, you comment out the corresponding HEADERS item
Serial.print( "HEADERS\t" ); Serial.print(millis()-timezero); Serial.print("\t"); ...
Serial.print( "eol\n" );
and
Serial.print( "DATA\t" );
________________________________________________________________________
Programmer notes, protocol
________________________________________________________________________
The Arduino recognizes the following commands
The arduino can send the following responses
![](https://www.google.com/images/icons/product/drive-32.png)
________________________________________________________________________
License and credits for mcjCommtty.exe
________________________________________________________________________
copyright 2018 mCasualJacques
permission to use in other programs is granted.
this is an almost unmodified version of commtty.c
by Robert Mashlan
copyright 1996 Robert Mashlan rmashlan@r2m.com
permission to use in other programs is granted.
http://nersp.nerdc.ufl.edu/~esi4161/files/commtty.c
________________________________________________________________________
// License and credits for mcjmpu6050
________________________________________________________________________
// mcjmpu6050.dsa by mCasual/Jacques c2018
// mcjmpu6050.ino by mCasual/Jacques c2018
// You can use this script freely for personal or commercial use.
// You may not sell, resell, sub-license or rent this script in any way.
// you may credit this script to mCasual/Jacques
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
__________________________________________