Tuesday, March 12, 2013

Disable sitecore cahe

To tern off sitecore caching set following values in sitecore config.
<!--  CACHING ENABLED
 Determines if caching should be enabled at all
 Specify 'true' to enable caching and 'false' to disable all caching
-->
<setting name="Caching.Enabled" value="false" />
<!--  DISABLE BROWSER CACHING
 If true, all pages will have:
   Cache-Control: no-cache, no-store
   Pragma: no-cache
 in the http header
-->
<setting name="DisableBrowserCaching" value="true" />

Monday, March 11, 2013

MSBuild copying all files in folder to destination folder

Typical task as for me, after build I want to copy some files from one location to other. All files that exist in folder. The not working approach looks like:
I would think that it should work, but it doesn't
<Target Name="AfterBuild">
<Copy SourceFiles="Foo\*.*" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>
The working solution is below
<ItemGroup>
    <_CopyDeployableAssemblies Include="Foo\*.*" />
</ItemGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(_CopyDeployableAssemblies)" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>
It will copy all files from folder Foo to Bin folder.

Sunday, March 10, 2013

Connecting lm298n with arduino


The connection is really strait forward. From arduino pins 6,7,5,4 connect accordingly to inputs IN1, IN2, IN3, IN4 in lm298n. And that's it, it will work. In terms of power supply, there are 2 power inputs in lm298n (5V, VCC), 5V can be connected to arduino, but if your motor requires more power, then you need to connect additional power supply to VCC. It is a really good practice to connect all GND cable together, I mean from additional power supply and from arduino. A code below increase a speed of two motors connected to lm298n and then decrease it.

I started recently my new mobile robotics project, and a picture shows a mobile framework connected to lm298n and arduino.
// Initialize
int PWM1   = 6; // PWM Pin Motor 1
int PoM1 = 7;   // Polarity Pin Motor 1
int PWM2   = 5; // PWM Pin Motor 2  
int PoM2 = 4;   // Polarity Pin Motor 2
 
int ValM1   = 0; // Initial Value for PWM Motor 1 
int ValM2   = 0; // Initial Value for PWM Motor 2
 
int i = 25;     // increment
// Used to detect acceleration or deceleration
boolean goUp = true ; 
 
void setup() 
{
  pinMode(PWM1,   OUTPUT); 
  pinMode(PoM1,   OUTPUT); 
  pinMode(PWM2, OUTPUT);   
  pinMode(PoM2, OUTPUT);   
  digitalWrite(PoM1, LOW) ;   // Both motor with same polarity
  digitalWrite(PoM2, LOW) ;
  analogWrite(PWM1, ValM1);   // Stop both motors => ValMx = 0
  analogWrite(PWM2, ValM2);    
  Serial.begin(9600);         // Used to check value 
}
 
// Main program
void loop()
{
  // give some time to the motor to adapt to new value
  delay (500) ;               
  if ((ValM1  < 250) && goUp) // First phase of acceleration
  {
      ValM1 = ValM1 + i ;     // increase PWM value => Acceleration
      ValM2 = ValM2 + i ;      
  }
  else
  {
    goUp = false ;            // Acceleration completed
    ValM1 = ValM1 - i ;       // Decrease PWM => deceleration
    ValM2 = ValM2 - i ;   
    // My motor made fanzy noise below 70  
    if (ValM1  < 75)           
    {                         // One below 75, I set to 0 = STOP
       ValM1 = 0 ;
       ValM2 = 0 ;
       goUp = true ;          // deceleration completed
    }
  }
  // If PWM values are OK, I send to motor controller
  if ((ValM1 > 75) && (ValM1 < 255))  
  {
    analogWrite(PWM1, ValM1);  
    analogWrite(PWM2, ValM2);
  }  
  Serial.print(ValM1);        // Debug. Print Value Motor 1
  Serial.print("\t");         // Print tab
  Serial.println(ValM2);      // Print Value Motor 2 to Serial
}
// End.

Wednesday, March 6, 2013

Reseting admin password in Sitecore

Sitecore inside Core db stores users information. In order to reset password to 'b' for a user 'admin' one has to run a following script
UPDATE [aspnet_Membership] SET Password='8dC23rEIsvuttG3Np1L4hJmJAOA=', PasswordSalt=' joeLPwcwMq6L7kyuVfVS7g=='   
WHERE UserId IN (SELECT UserId FROM [aspnet_Users] WHERE UserName = 'sitecore\Admin') 
It is important to set both Password and PasswordSalt.